gpt4 book ai didi

升级到新的 jQuery 版本后 jQuery 将不会返回数据

转载 作者:行者123 更新时间:2023-12-01 07:34:23 37 4
gpt4 key购买 nike

我将 jQuery 版本从 1.3 升级到 1.4。我的代码在 1.3 中运行良好,但在 1.4 中却不行。我到底做错了什么?

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");
}

非常感谢大家对我的帮助:)

最佳答案

在 jQuery 1.4+ 中 your JSON has to be valid ,这方面要严格得多。检查您在 Firebug、Chrome、Fiddler 或任何其他工具中获得的服务器响应,看看它是否有效:http://www.jsonlint.com/

如果不是,这是服务器端问题,请确保输出 valid JSON :)

关于升级到新的 jQuery 版本后 jQuery 将不会返回数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3638258/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com