1

リンクをクリックすると、をpost介して送信する必要がありますajax。問題は、リンクを開いたためにリクエストがドロップされることです。

jQuery('#pagination a').click(function(){
    jQuery.post('index.php?option=com_component',
        {checked_sites_for_session: jQuery('.selected-site input[type="checkbox"]').map(function () {return this.value;}).get()}
    ).success(function(){window.location = jQuery(this).attr('href')});
    console.log(jQuery(this).attr('href'));
    return false;
});

しかし、ここでも問題は(joomlaのおかげで)urlにあり/~user/joomla/index.php/view-sites?view=sites&page=2ます-それはスラッシュから始まりますが、実際のリンクはですhttp://localhost/~user/joomla/index.php/view-sites?view=sites&page=2が、ソースには<a href="index.php?option=com_component&view=sites&。'。$option.'page='。$leftがあります。 '"//....`

したがって、「多目的ドメイン解析ソリューション」が必要です。または、joomlaがURLを変更するのをやめてください。

4

2 に答える 2

2

ネイティブelement.hrefを使用すると、属性値だけでなく、ドメインを含むhref全体が取得されます。またthis、$、post関数内で使用されているキーワードにスコープの問題があります。

$('#pagination a').on('click', function(e){
    e.preventDefault();
    var self = this;
    $.post('index.php?option=com_component',
        {checked_sites_for_session: $('.selected-site input[type="checkbox"]').map(function () {
                 return this.value;
            }).get();
        }
    ).success(function(){
        window.location = self.href;
    });
});

あなたが投稿したリンクから、それらはまったく同じようには見えないので、いくつかのCMSソリューションは書き換えなどを使用しているので、そのために何かを理解する必要があるかもしれません。

于 2012-11-21T10:20:59.193 に答える
-1

これに関する問題

    jQuery('#pagination a').click(function(e){
    e.preventDefault();
var me=this;
        jQuery.post('index.php?option=com_component',
            {checked_sites_for_session: jQuery('.selected-site input[type="checkbox"]').map(function () {return this.value;}).get()}
        ).success(function(){window.location = jQuery(this).attr('href')});
        console.log(jQuery(me).attr('href'));
        return false;
    });
于 2012-11-21T10:20:45.143 に答える