[英]jquery ajax request not responding
I'm a newbie at asp.net
and trying to understand ajax
responses. 我是asp.net
的新手并试图理解ajax
响应。 I have following code: 我有以下代码:
$(document).ready(function () {
$('#<%=cbx_pep.ClientID%>').change(function () {
var mSis = $('#<%=cbx_pep.ClientID%>').val();
getRCT(mSis);
});
});
function getRCT(mez_sis) {
$.ajax({
url: '/Staff/PEX.aspx/GetTempInfo',
method: 'get',
contentType: 'application/json',
data: '{d_val:' + mez_sis + '}',
dataType: 'json',
success: function (data) {
alert(data.d);
},
error: function (error) {
alert(error);
}
});
}
and that's my server side code: 那是我的服务器端代码:
[WebMethod]
public static string GetTempInfo(string d_val)
{
string str = d_val;
return str;
}
I'm repeatedly getting error. 我一再得到错误。 Appreciate for help. 感谢您的帮助。
First, as mybrithname said, You have yo use method: 'post'
and then your json is invalid, you have a missing quotes there: 首先,正如mybrithname所说,你有使用method: 'post'
,然后你的json无效,那里你有一个缺失的引号:
It should be something like this 它应该是这样的
data: '{d_val:\"' + myVar + '\"}',
你应该使用method: 'post'
如果你要将数据发送到服务器,你在data: '{d_val:' + mez_sis + '}'
中做的是data: '{d_val:' + mez_sis + '}'
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.