"消息":"无效的Web服务调用,参数缺失值:\\ u0027 [英] "Message":"Invalid web service call, missing value for parameter: \u0027

查看:1256
本文介绍了"消息":"无效的Web服务调用,参数缺失值:\\ u0027的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到这个错误时,我送2参数从jQuery来的WebMethod,并使用多个PARAMS。

I got this error when i send 2 parameter from jQuery to WebMethod and using multiple params.

{"Message":"Invalid web service call, missing value for parameter: \u0027haha\u0027.","StackTrace":"   at System.Web.Script.Services.WebServiceMethodData.CallMethod(Object target, IDictionary`2 parameters)\r\n   at System.Web.Script.Services.WebServiceMethodData.CallMethodFromRawParams(Object target, IDictionary`2 parameters)\r\n   at System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext context, WebServiceMethodData methodData, IDictionary`2 rawParams)\r\n   at System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext context, WebServiceMethodData methodData)","ExceptionType":"System.InvalidOperationException"}

在jQuery的:

$(".txtNoiDung").focusout(function () {
        $.ajax({
            type: "POST",
            url: "QuanLyTin.aspx/test1cai",
            data: JSON.stringify({ hahas: $(this).val(),tuans: "hahaha" }),
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            success: function (msg) {
                $("#vltxtNoiDung").text(msg.d)
            },
            error: function (xhr, reason, ex) {
                alert(reason);
            }
        });
    });

在code后面

 [WebMethod()]
        public static string test1cai(string haha, string tuan)
        {
            return "Hi, "+haha + tuan;
        }

我该如何解决呢?
谢谢你们。

How can i resolve it? Thanks you guys.

推荐答案

您服务正在接受命名参数哈哈,但你的JavaScript在 haha​​s 和 tuans 。从两个删除的S:

Your service is accepting parameters named haha and tuan, but your JavaScript is passing in hahas and tuans. Remove the "s" from both:

data: JSON.stringify({ haha: $(this).val(),tuan: "hahaha" }),

另外,请记住,这些参数区分大小写客户端和服务器端的之间没有太大的匹配

这篇关于"消息":"无效的Web服务调用,参数缺失值:\\ u0027的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆