错误:在asp.net中未定义$ ajax

时间:2013-12-17 07:42:57

标签: jquery asp.net ajax

在将值传递给我的方法时,我面临以下错误:

  

错误未捕获的ReferenceError:$ ajax未定义

这是我的代码:

$ajax({
    type: "POST",
    url: 'UserWebService.asmx/addDetails',
    data: "{'name':'" + name + "'}",
    contentType: "application/json; charset-utf-8",
    dataType: "json",
    success: function (response) {
        var result = response.d;
        alert(result);
    },
    failure: function (msg) {
        alert(msg);
    }
});

我希望有人可以回答我的问题。

提前致谢

2 个答案:

答案 0 :(得分:7)

看起来你正在使用jQuery - 它应该是

$.ajax(...

答案 1 :(得分:0)

您可以使用:

jQuery.ajax({ 
    type: "POST",
    url: 'UserWebService.asmx/addDetails',
    data: "{'name':'" + name + "'}",
    contentType: "application/json; charset-utf-8",
    dataType: "json",
    async: false,
    success: function (response) {
        var result = response.d;
        alert(result);
    },
    failure: function (msg) {
        alert(msg);
    }
});