作者:豆皮没有豆

微信小程序 “因 URL 意外地以“XXX”结束,请求格式无法识别”及post返回数据包含d:null的解决方法

一.因 URL 意外地以“XXX”结束,请求格式无法识别

该问题的解决方法如下:在web.config的system.web中,添加如下代码:

    <webServices>
      <protocols>
        <add name="HttpGet"/>
        <add name="HttpPost"/>
      </protocols>
    </webServices>

在这里插入图片描述

二.post请求返回数据包含d:null

一般情况下默认header:

header: {'content-type': 'application/json'},//默认值

修改后:

header: {'content-type': 'application/x-www-form-urlencoded;charset=utf-8'},

在这里插入图片描述
在这里插入图片描述