我的脚本代码:
$('#btnSave').click(function() {
var pageUrl = '<%= ResolveUrl("`/TestPage.aspx/SystemEdit")%>';
var ip = $('#editIP').text();
var loc = $('#txtBay').val();
var team = $('#txtTeam').val();
var port = $('#txtPort').val();
var xcel = "", office = "", moni = "";
var parameter={ "ip": ip, "loc": loc, "team": team, "port": port, "excel": xcel, "office": office, "monitor": moni}
$.ajax({
type: 'POST',
url: pageUrl,
data: JSON.stringify(parameter),
contentType: 'json',
success: function(data) {
alert(data);
},
error: function(data,success,error) {
alert("Error:" +error);
}
});
});
我在c#代码后面的代码是:
[WebMethod]
public static string SystemEdit(string ip, string loc,string team, string port, string excel,string office, string monitor)
{
Thread.Sleep(1000);
return "success";
}
我的网页名称是: TestPage.aspx
点击保存按钮时,我收到'未找到'错误。
答案 0 :(得分:0)
请检查以下事项:
1. your static method not including [webmethod] attribute.
2. your url is incorrect(change "`/TestPage.aspx/SystemEdit" to
"~/TestPage.aspx/SystemEdit")
3. is your save button is server side or client side.
i hope it helps you