的職位被解僱,我可以看到下面的螢火jQuery的AJAX-C#成功的功能,但沒有任何反應
POST http://localhost:1148/WebSite2/frmMain.aspx/webDelete 200 OK 15ms
jQuery代碼是:
$.ajax({
url: "frmMain.aspx/webDelete",
type: "POST",
dataType: "text",
contentType:"text/plain",
data: {id:"abc"},
success: function(data){alert("success");alert(data)},
error: function(){alert("failed");}
});
然後兩個警報在成功功能被解僱但第二次提醒爲空
服務器端編碼:
[WebMethod][ScriptMethod]
public static string webDelete(string id)
{
HttpContext context = HttpContext.Current;
context.Response.ContentType = "text/plain";
return id;
}
目前正在努力沒有參數的時受累,誤差函數是triggeres,沒有成功
jQuery代碼
$.ajax({
url: "frmMain.aspx/webDelete",
type: "POST",
dataType: "json",
contentType: "application/json; charset=utf-8",
data: "{}",
async: true,
success: function(data){alert("success");alert(data.d) },
error: function(){alert("failed"); }
});
服務器代碼
[WebMethod][ScriptMethod]
public static string webDelete()
{
return "hello";
}
螢火蟲信息:
響應頭
Cache-Control private
Connection Close
Content-Length 11732
Content-Type text/html; charset=utf-8
Date Thu, 18 Jul 2013 09:47:34 GMT
Server ASP.NET Development Server/8.0.0.0
X-AspNet-Version 2.0.50727
請求頭
Accept application/json, text/javascript, */*; q=0.01
Accept-Encoding gzip, deflate
Accept-Language en-US,en;q=0.5
Content-Length 2
Content-Type application/json; charset=utf-8
Host localhost:1148
Referer http://localhost:1148/WebSite2/frmMain.aspx
User-Agent Mozilla/5.0 (Windows NT 5.2; rv:22.0) Gecko/20100101 Firefox/22.0
X-Requested-With XMLHttpRequest
1.代碼是沒有得到執行2.實際響應是在客戶端頁面3.怎樣的HTML代碼引起的在此評論中添加新行!? – rps
什麼也沒有發生,我沒有在firebug中看到任何ajax文章,所以沒有請求,也沒有響應,如果我點擊那個url,頁面就會加載。 – rps
啓用GET方法? – rps