【发布时间】:2012-02-24 18:43:51
【问题描述】:
我第一次使用来自 asax 页面的 ajax 调用。
它工作正常我在 C# 页面中获取数据,但是当尝试获取成功函数时,我在错误函数中得到错误消息
“SyntaxError: JSON.parse: 意外字符”
这是我的代码
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");
}
谢谢。
【问题讨论】:
-
什么是数据?显示字符串
-
1-800-optisource.com/Email/image/jsonstring.jpg" width="497" height="394"/>