小编laz*_*wer的帖子

JQuery和Ajax - 陷入困境

我已经阅读了网上关于使用JQuery发布ajax的几个教程,所有这些教程都引用了来自Web服务的响应对象作为响应/响应.这让我相信这是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);
        }
    });
});
Run Code Online (Sandbox Code Playgroud)

但是代码在Chrome的Javascript控制台中返回"Uncaught ReferenceError:response not defined".我做了什么假设,我需要重新评估.

asp.net ajax jquery web-services

2
推荐指数
1
解决办法
453
查看次数

标签 统计

ajax ×1

asp.net ×1

jquery ×1

web-services ×1