我一直在用以下C#/ jQuery获得500。任何给定的实现可能都不对,这不是一个大问题。我只是试图让一个你好的世界了。它的工作原理如果C#没有参数,但只要我尝试收到的数据也给出了500ASP.NET hello world AJAX post
[WebMethod]
public static string Test(string s)
{
// never gets here
}
$.ajax({
type: "POST",
url: "ajax.aspx/" + method,
/*async: true,*/
data: "{data:'" + data + "'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
callback(data.d);
}
});
最新尝试是这仍然不工作:
[WebMethod()]
public static string Test(string data)
{
// never gets here
return "hello world";
}
$.ajax({
type: "POST",
url: "ajax.aspx/Test",
data: "data: {data:'abc'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (data) {
alert("back");
}
});
如何设置'data'?在'data:“{data:'”+ data +“'}”' – 2012-07-30 00:14:20
数据变量是一个没有引号的字符串。即数据是 - > abcdefg – 2012-07-30 00:16:28
您正在使用什么URL来尝试访问该控制器方法? – 2012-07-30 03:51:50