我有這個AJAX代碼,但它似乎並沒有拋出'alert'方法。相反,沒有任何反應。我看着它與提琴手和得到這個錯誤信息: {"Message":"There was an error processing the request.","StackTrace":"","ExceptionType":""}
簡單的AJAX不工作
我想調用的代碼隱藏稱爲MyWebMethod
一個Web方法:
$.ajax({ type: "POST",
url: "Test.aspx/MyWebMethod",
data: "{" + username + "}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function() {
alert("success");
},
fail: function() {
alert("Fail");
}
});
Web方法工作得很好,當我有一個頁面上的腳本管理器,但我想刪除腳本管理器,並認爲使用AJAX將是最好的方法。
感謝
首先嚐試使用NO數據,調用將返回類似服務器時間戳的內容...作爲字符串並提醒。確保你的web方法名稱「用戶名」匹配...編輯:我尾隨在頁面上的編輯...在這一點上可能不相關... – 2010-03-10 22:33:13