我正在使用jquery ajax方法來調用一個webmethod在單擊'span'時。這是webmethod是在我的aspx頁之一,我使用以下代碼從母版頁調用它。
$(document).ready(function(){
$("#btn").click(function() {
$.ajax({
type: "POST",
url: "Default.aspx/removedata",
data:"{}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success:function(msg) {
$("li#search").removeClass('current');
$("li#search").addClass('hide');
$("#tabnew").addClass('hide');
window.location="Result.aspx";
},
error:function(xhr, status, error) {
alert("error");
//var err = eval("(" + xhr.responseText + ")");
// Display the specific error raised by the server
//alert(err.Message);
console.log(xhr.statusText);
}
});
});
});
當我點擊的跨度,我可以看到越來越調用(通過調試)將WebMethod,但即使之前將WebMethod開始執行我得到的警報「錯誤」,我看(空字符串)消息被登錄到螢火蟲控制檯。 據我所知只有在ajax請求失敗時纔會執行'error'函數。但是我可以看到webmethod得到執行。我不明白爲什麼錯誤函數正在執行。
有人可以幫助我這個。
感謝
你做任何網址重寫? – Aristos 2010-08-18 14:21:34
不,我沒有進行url rewrite.actually我只是刪除存儲在我調用的webmethods的會話中的一些數據。 – kranthi 2010-08-18 14:27:35
返回的狀態是什麼? – 2010-08-18 14:34:22