在我的aspx页面,我对JS是这样的: -jQuery的AJAX发送数据键值对
$("#btnLoad").click(function() {
var dataForAjax = "{'datakey':'hello'}"
$.ajax({
type: "POST",
url: "Ajax__Demo.aspx/SendFile",
data: dataForAjax,
success: function (msg) {
alert(msg); // Problem with this line. It is not showing the value.
}
});
});
在隐藏类文件相同的网页代码,我有这样的定义将WebMethod: -
[WebMethod]
public static string SendFile(string key, string data)
{
return data;
}
出于某种原因,我能够获得在html端使用的警报数据。警报(MSG);没有给我任何东西,我希望能够获得通过的价值。在这种情况下,它应该是'你好'。
我错过了这里很小的东西,请帮我看看这里。
2011-07-20
Karan