【发布时间】:2011-01-20 18:23:20
【问题描述】:
我已经阅读了网络上关于使用 JQuery 进行 ajax 发布的几个教程,它们都将来自网络服务的响应对象引用为 response / response.d -- 这让我相信这是内置对象用于 JQuery 的响应处理程序。
代码片段:
$('.submit').click(function () {
var theURL = document.location.hostname + ":" + document.location.port + "/LeadHandler.aspx/hello"; // this will change too
alert(theURL);
$.ajax({
type: "POST",
url: theURL,
data: "{'NameFirst':'" + $('#txtFirstName').val() + "'}", // again, change this
contentType: "applications/json; charset=utf-8",
dataType: "json",
success: alert("Success: " + response.d), // this will change
failure: function (response) {
alert("Failure: " + response.d);
}
});
});
但是,代码在 Chrome 的 Javascript 控制台中返回“未捕获的 ReferenceError:未定义响应”。我做了哪些假设需要重新评估。
【问题讨论】:
标签: asp.net jquery ajax web-services