Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/73.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 为什么ajax调用的json数据最终成为querystring参数?_Javascript_Jquery_Ajax - Fatal编程技术网

Javascript 为什么ajax调用的json数据最终成为querystring参数?

Javascript 为什么ajax调用的json数据最终成为querystring参数?,javascript,jquery,ajax,Javascript,Jquery,Ajax,我有以下ajax调用。我想以jason格式发送数据。然而,我注意到在Fiddler中,数据被转换为查询字符串参数。我做错了什么 $.ajax({ type: "GET", url: "StatusService.svc/CheckStatus", data: JSON.stringify({"companyName":"paymins"}), contentType: "application/json; charset=utf

我有以下ajax调用。我想以jason格式发送数据。然而,我注意到在Fiddler中,数据被转换为查询字符串参数。我做错了什么

  $.ajax({
        type: "GET",
        url: "StatusService.svc/CheckStatus",
        data: JSON.stringify({"companyName":"paymins"}),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            alert('ok!');
            alter(data.toString());
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(textStatus + ' / ' + errorThrown);
        }
    });

将请求的类型更改为post

  $.ajax({
        type: "POST",
        url: "StatusService.svc/CheckStatus",
        data: JSON.stringify({"companyName":"paymins"}),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            alert('ok!');
            alter(data.toString());
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(textStatus + ' / ' + errorThrown);
        }
    });

将请求的类型更改为post

  $.ajax({
        type: "POST",
        url: "StatusService.svc/CheckStatus",
        data: JSON.stringify({"companyName":"paymins"}),
        contentType: "application/json; charset=utf-8",
        dataType: "json",
        success: function (data) {
            alert('ok!');
            alter(data.toString());
        },
        error: function (jqXHR, textStatus, errorThrown) {
            alert(textStatus + ' / ' + errorThrown);
        }
    });

Get不能包含正文。请使用post。Get不能包含正文。请使用post。

因为您正在执行
get
请求。请注意
dataType:“json”
告诉jQuery响应的预期格式,而不是请求的格式。因为您正在执行
get
请求。请注意
dataType:“json”
告诉jQuery响应的预期格式,不是请求的格式。请尝试将标题指定为已更新。这是我自己的WCF服务配置问题。谢谢大家。请尝试将标题指定为已更新。这是我自己的WCF服务配置问题。谢谢大家。