使用jQuery“无效的Web服务调用,缺少参数值”

问题描述 投票:0回答:2

我有一个使用WebForms的网站。它有一个曾经工作的服务,但我的主机最近将该站点迁移到新服务器。数据库连接正在运行,但我的asmx服务现已中断。

我有这个签名:

[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
[WebMethod]
public string GetJarLabel(string type, string serialized)
{

我正在使用这个jQuery调用:

var requestData = {
            "type":  "jam",
            "serialized": JSON.stringify(data)
};
$.ajax({
            type: "POST",
            url: "/Labels.asmx/GetJarLabel",,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            processData: false,
            data: JSON.stringify(requestData),
            error: function(xhr, status, ex) {
                ...snip
            },
            success: function(r) {
                ...snip
            }
        });

enter image description here

这个请求似乎是我可以提交的,但服务响应500: Invalid web service call, missing value for parameter: 'type'.我尝试过切换到GET,字符串化,而不是字符串化,但没有任何作用。我确信这在迁移之前有效,但是看不出它会如何影响它。

jquery asp.net ajax web-services asmx
2个回答
1
投票

下面你可以看到你的ajax电话。你正在使用一个叫做lblData的东西。那是什么?这不是你在上面宣布的。尝试通过requestData代替。

$.ajax({
        type: "POST",
        url: "/Labels.asmx/GetJarLabel",,
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        processData: false,
        data: JSON.stringify(lblData),
        error: function(xhr, status, ex) {
            ...snip
        },
        success: function(r) {
            ...snip
        }
    });

我假设无论lblData是什么,它都没有type的定义。


0
投票

我今天在家里的另一台机器上试过这个(以前在工作)。似乎工作有某种奇怪的出站代理设置干扰请求。我想这一课是尝试来自不同国家或手机的VPN。

© www.soinside.com 2019 - 2024. All rights reserved.