开发者

jQuery will not return data after upgrading to new jQuery version

I upgraded my jQuery version to 1.4 from 1.3. My code worked fine in 1.3, but it doesn't in 1.4. What can I have done wrong?

function add_product_to_shopping_开发者_运维百科cart( product_id )
{
    $.post("/actions/etrade/add_product_to_cart",
    {
        'product_id': product_id,
        'variant_first': $('#main_variant-'+ product_id ).val(),
        'variant_secound': $('#secound_variant-'+ product_id ).val(),
        'stock': $('#stock-'+ product_id ).val()
    }, function(data) {
        if ( data.err == 0 )
        {
            $('#cart_count').html( data.item_count );
            $('#cart_price').html( data.cart_total_price );
            $('#cart_shop_more').fadeIn();
        }
        else
        {
            alert( data.err_msg );
        }

        alert('test');
    },"json");  
}

Thanks a lot all for helping me :)


In jQuery 1.4+ your JSON has to be valid, it's a lot stricter about this. Check the server response you're getting in Firebug, Chrome, Fiddler, or any other tool and see if it's valid here: http://www.jsonlint.com/

If it's not, this is a server-side problem, make sure you're outputting valid JSON :)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜