该帖子已被解雇,我可以在萤火虫中看到以下内容
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;
}
目前正在尝试没有param的参与,错误功能是触发器,没有成功
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