I do not know why this do not work(can not call SendValues method).There is no error raise up. Can anyone help me ? Thank you very much!
The html page some thing like below:
<script language="javascript" type="text/javascript">
$(function () {
$("#Button1").click(function () {
$.ajax({
type: "POST",
url: "WebForm1.aspx/SendValues",
data: { 'Code': '1026' },
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (json) {
alert(json.d);
},
failure: function () {
alert("Sorry,there is a error!");
}
});
});
});
</script>
The c# code Some thing like:
public partial class WebForm1 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
[WebMethod]
public static string SendValues(string Code)
{
string contects = string.Empty;
return contects;
}
}
我已经通过将数据{{'Code':'1026'}修改为“ data:{'Code':'1026'}”解决了这个问题
数据应指定为
data: '{ Code:["1026"]}'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.