我在 Test.aspx 页面中有一个 ajax 请求
$.ajax({
type: "POST",
url: "Test.aspx/TestMethod",
data: "{ 'Parameter':'Parameter'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (res) {
alert('success');
},
error: function (xhr, ajaxOptions, thrownError) {
alert('error getting Regions');
}
});
以及后面的代码
[WebMethod()]
public static string TestMethod(string Parameter)
{
return "teststring";
}
问题是控制在 ajax 中无法成功,知道吗?''
最佳答案
试试这个
$.ajax({
type: "POST",
url: "Test.aspx/TestMethod",
data: "{ 'Parameter':'Parameter'}",
contentType: "application/json; charset=utf-8",
success: function (res) {
var s = JSON.stringify(res);
alert(s);
},
error: function () {
alert('error getting Regions');
}
});
关于javascript - ajax 调用 webmethod 在 asp.net 中未成功,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23926498/