我试图调用Web服务,并始终得到一个错误,该错误警报显示“未定义”jquery的asp.net web服务调用不工作
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public static string Test()
{
JavaScriptSerializer js = new JavaScriptSerializer();
return js.Serialize("Hello");
}
这是脚本
$.ajax({ type: "POST",
contenttype: "application/json; charset=utf-8",
data: "{}",
url: "WorkflowAjaxHelper.asmx/Test",
dataType: "json",
async: false,
success: function (res) {
alert('success');
},
error: function (err) {
alert(err.text);
}
});
你不应该看err.responseText吗? JS调试器非常方便。 – 2012-07-19 14:14:28
感谢保罗,当更改这个错误是'测试web服务名称无效' – jorgechess 2012-07-19 14:28:00