1
我想在ASP.Net使用jQuery Ajax和我用下面的代碼在JavaScript調用的WebMethod用的MapPageRoute jQuery中
$(function() {
$('#click').click(function() {
$.ajax({
type: "POST",
url: "mine/HelloAgain",
data: JSON.stringify({ID : 236 , Name : "Milad"}),
contentType: "application/json",
dataType: "json",
success: function (msg) {
$("#Result").text(msg.d);
}
});
});
});
如您在網址看到我使用[礦山/ HelloAgain]我創建全局路由在此代碼
routes.MapPageRoute("Mine",
"mine/{*locale}",
"~/tst/Test.aspx/HelloAgain",
true
);
但返回404 Not Found錯誤此的WebMethod我想打電話給
[WebMethod]
public static string HelloAgain(int ID, string Name)
{
return ID.ToString() + " Hello " + Name + DateTime.Now.ToString();
}
任何幫助可以理解的