1

jQueryを使用して、JavaScriptで作成された関数があります。これを使用して、サーバーに情報を送信します

function cart(val, theImg)
{
    var url = location.protocol+'//'+location.hostname+'/';
    if(!theImg.hasClass('added'))
    {
        jQuery.post(url,{ajax:'1',compedit:'shopping-cart',q:'1',tocart:val},function(result){
            theImg.attr({'src':'/media/images/substract_from_cart.png','title':'Substract from cart','alt':'Substract from cart'}).addClass('added');
            jQuery('.btip').text('Substract From Cart');                 
        }, 'text');
    }
    else
    {
        jQuery.post(url,{'ajax':'1','compedit':'shopping-cart','q':'0','tocart':val},function(result){
            theImg.attr({'src':'/media/images/add_to_cart.png','title':'Add To Cart','alt':'Add To Cart'}).removeClass('added');
            jQuery('.btip').text('Add To Cart');                 
        }, 'text');
    }
}

私の問題は、この関数が Webkit ブラウザー (Chrome、Safari) のサーバーにデータを送信しないことです! どんな助けでも大歓迎です!

4

1 に答える 1

2

最初postは正しくありません追加':

 jQuery.post(url,{'ajax':'1','compedit':'shopping-cart','q':'1','tocart':val}..
于 2012-05-15T12:47:01.767 に答える