我正在尝试调用 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);
}
});