admin管理员组文章数量:1332352
I'm a newbie in Jquery Ajax. I need your help. I want to display one text beside span element. I have already done reference some topics but i cant resolve it
Here is my error in firebug (newlines and indentation added)
{"Message":"Invalid web service call, missing value for parameter: \u0027haha\u0027.", "StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters) at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters) at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)", "ExceptionType":"System.InvalidOperationException"}
In aspx
<asp:TextBox ID="txtNoiDung" runat="server" TextMode="MultiLine" CssClass="txtNoiDung"></asp:TextBox><span id="vltxtNoiDung"></span>
In code behind
[WebMethod()]
public static string test1cai(string haha)
{
return haha;
}
In Javascript
$(".txtNoiDung").focusout(function () {
var dataToSend = { names: $(this).val() };
$.ajax({
type: "POST",
url: "QuanLyTin.aspx/test1cai",
data: JSON.stringify(dataToSend),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$("#vltxtNoiDung").text(msg.d)
},
error: function (xhr, reason, ex) {
alert(reason);
}
});
});
Thanks in advance!
I'm a newbie in Jquery Ajax. I need your help. I want to display one text beside span element. I have already done reference some topics but i cant resolve it
Here is my error in firebug (newlines and indentation added)
{"Message":"Invalid web service call, missing value for parameter: \u0027haha\u0027.", "StackTrace":" at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters) at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters) at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams) at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)", "ExceptionType":"System.InvalidOperationException"}
In aspx
<asp:TextBox ID="txtNoiDung" runat="server" TextMode="MultiLine" CssClass="txtNoiDung"></asp:TextBox><span id="vltxtNoiDung"></span>
In code behind
[WebMethod()]
public static string test1cai(string haha)
{
return haha;
}
In Javascript
$(".txtNoiDung").focusout(function () {
var dataToSend = { names: $(this).val() };
$.ajax({
type: "POST",
url: "QuanLyTin.aspx/test1cai",
data: JSON.stringify(dataToSend),
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
$("#vltxtNoiDung").text(msg.d)
},
error: function (xhr, reason, ex) {
alert(reason);
}
});
});
Thanks in advance!
Share Improve this question edited Nov 6, 2011 at 16:59 tuan.it89 asked Nov 6, 2011 at 16:37 tuan.it89tuan.it89 3131 gold badge3 silver badges10 bronze badges2 Answers
Reset to default 7Change data: JSON.stringify(dataToSend),
to
data: JSON.stringify({
haha: $(".txtNoiDung").val()
}),
This is assuming that $(".txtNoiDung")
is unique in the page, if it's not, you'll need another mechanism for getting the value. I'm pretty sure you can get away with $(this).val())
to get the value in this case.
The parameter name from the method should always be same with parameter passed in the data for an Ajax call. instead of names in data use haha(parameter from c# method).
本文标签:
版权声明:本文标题:javascript - "Message":"Invalid web service call, missing value for parameter: u0027hahau0027 - Stack 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742321099a2452800.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论