我在asp.net中使用jquery ajax調用,我有一個靜態的web方法的一些參數,當我試圖調試它沒有擊中該方法,我在錯誤日誌中看到它的顯示parseError,我刪除了所有參數和檢查,但還是同樣的錯誤,在ASP.net jQuery Ajax調用錯誤
[WebMethod]
private static void AddData(int type, int categ, string desc, string date, string city, string state)
{
//Do Processing
}
我也試過這個,但同樣的錯誤
[WebMethod]
private static void AddData()
{
//do Processing
}
這是我的Ajax調用
$.ajax({
type: "POST",
url: 'MyPage.aspx/AddData?type=' + encodeURIComponent(crimetype) + "&categ=" + encodeURIComponent(crimecateg) + "&desc=" + encodeURIComponent(desc) + "&date=" + encodeURIComponent(crimedate) + "&city=" + encodeURI(city) + "&state=" + encodeURIComponent(stateid),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
},
error: function (data, errorThrown) {
debugger
alert(errorThrown);
alert(data.toString());
}
});
我這個嘗試以及
$.ajax({
type: "POST",
url: 'MyPage.aspx/AddData',
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
},
error: function (data, errorThrown) {
debugger
alert(errorThrown);
alert(data.toString());
}
});
所有參數都傳遞正確
並把網址中的**」「**,而不是**「**改變什麼? – Rohan