C# 获得;SyntaxError:JSON.parse:意外字符;从asp.net中的用户控件页进行ajax调用时出错
我使用来自asax页面的第一次ajax调用 它工作得很好,我在C#页面中获取数据,但当尝试使用get success函数时,我在error函数中获取了error msg “SyntaxError:JSON.parse:意外字符” 这是我的密码C# 获得;SyntaxError:JSON.parse:意外字符;从asp.net中的用户控件页进行ajax调用时出错,c#,asp.net,json,jquery,C#,Asp.net,Json,Jquery,我使用来自asax页面的第一次ajax调用 它工作得很好,我在C#页面中获取数据,但当尝试使用get success函数时,我在error函数中获取了error msg “SyntaxError:JSON.parse:意外字符” 这是我的密码 var options = { type: "POST", url: "ChemistrieAddToCart.aspx", data: data, contentType: "app
var options = {
type: "POST",
url: "ChemistrieAddToCart.aspx",
data: data,
contentType: "application/json; charset=utf-8",
dataType: "json",
async: false,
success: function () {
alert("sucsess");
},
error: function (xhr, status, error) {
alert("failed" + xhr.responseText);
alert(error);
alert(status);
}
};
var returntext = $.ajax(options).responseText;
if (returntext = "added") {
alert("Matched");
window.location="shoppingcart.aspx"
}
else {
alert("not completed");
}
谢谢。如果您将
作为Json字符串传递,则它是错误的,您可能会先查看Json格式,然后再传递该值,这可能会让您了解并解决您的问题
检查这里的json:什么是数据?显示字符串