以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- Ajax提交后,服务器报错:值不能为null,参数名s (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=175660) |
-- 作者:chenjiu6202 -- 发布时间:2022/3/14 16:12:00 -- Ajax提交后,服务器报错:值不能为null,参数名s 一、Ajax提交部分: mui.ajax(\'http://192.168.2.73/checkPhone.htm\',{ data:{phone:phone}, async: true, dataType:\'json\',//服务器返回json格式数据 type:\'post\',//HTTP请求类型 timeout:10000,//超时时间设置为10秒; headers:{\'Content-Type\':\'application/json\'}, success: function(rsp){ }, error:function(xhr,type,errorThrown){ //异常处理; console.log(type); } }); 二、接受代码: Dim e As RequestEventArgs = Args(0) Dim jo As JObject = JObject.Parse(e.PlainText) \'解析JSON 三、报错图片: |
-- 作者:chenjiu6202 -- 发布时间:2022/3/14 16:12:00 -- 哪个老师麻烦看看怎么回事,会经常出现! |
-- 作者:有点蓝 -- 发布时间:2022/3/14 16:24:00 -- 调试技巧:http://www.foxtable.com/webhelp/scr/1485.htm,看哪一句代码出错 |
-- 作者:chenjiu6202 -- 发布时间:2022/3/14 16:40:00 -- e.PlainText 传过来没有,直接报错 |
-- 作者:有点蓝 -- 发布时间:2022/3/14 17:14:00 -- 使用日志跟踪一下,看看都接收了什么数据:http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=173590 \'\'记录接收的消息,方便分析,用于调试 Dim str As new StringBuilder str.AppendLine("Headers:---------------") For Each key As String In e.Request.Headers.AllKeys str.AppendLine(key & " = " & e.Request.Headers(key)) Next str.AppendLine("Headers:---------------") str.AppendLine("host=" & e.Host) str.AppendLine("port=" & e.Port) str.AppendLine("path=" & e.Path) str.AppendLine("HttpMethod=" & e.Request.HttpMethod) str.AppendLine("poststring=" & e.PlainText) \'str.AppendLine("ip=" & e.Request.RemoteEndPoint().Address.ToString()) str.AppendLine("url=" & e.Request.URL.ToString) str.AppendLine("getValues:---------------") For Each key As String In e.getValues.Keys str.AppendLine(key & "=" & e.getValues(key)) Next str.AppendLine("postValues:---------------") For Each key As String In e.PostValues.Keys str.AppendLine(key & "=" & e.PostValues(key)) Next \'----------file For Each key As String In e.Files.Keys str.AppendLine(key & " 上传" & e.Files(key).Count & "个文件,分别是:") For Each fl As String In e.Files(key) str.AppendLine(fl) Next Next \'----------file |
-- 作者:chenjiu6202 -- 发布时间:2022/3/15 9:12:00 -- 经过和pc浏览器对比测试,发现以下问题,这怎么修改呢? 手机浏览器 输出Headers:--------------- Access-Control-Request-Method = POST Access-Control-Request-Headers = content-type,x-requested-with Origin = http://192.168.2.73:8848 Sec-Fetch-Mode = cors X-Requested-With = com.tencent.mm Connection = keep-alive Accept = */* (应该是 application/json) Accept-Encoding = gzip, deflate Accept-Language = zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7 Host = 192.168.2.73 Referer = http://192.168.2.73:8848/YiTaiApp/htmlFirst/checkPass.html User-Agent = Mozilla/5.0 (Linux; Android 9; MHA-AL00 Build/HUAWEIMHA-AL00; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/86.0.4240.99 XWEB/3193 MMWEBSDK/20220105 Mobile Safari/537.36 MMWEBID/3010 MicroMessenger/8.0.19.2080(0x2800133D) Process/toolsmp WeChat/arm64 Weixin NetType/WIFI Language/zh_CN ABI/arm64 Headers:--------------- host=192.168.2.73 port=80 path=checkPhone.htm HttpMethod=OPTIONS (应该是 POST) poststring= (应该是{"phone":"12345678900"}) url=http://192.168.2.73/checkPhone.htm getValues:--------------- postValues:--------------- pc电脑谷歌浏览器 输出Headers:--------------- Origin = http://127.0.0.1:8848 X-DevTools-Emulate-Network-Conditions-Client-Id = (4629CA3138903C05B728F1F133DEC5D) X-Requested-With = XMLHttpRequest Connection = keep-alive Content-Length = 23 Content-Type = application/json Accept = application/json Accept-Encoding = gzip, deflate Accept-Language = en-US,en;q=0.9 Host = 192.168.2.73 Referer = http://127.0.0.1:8848/YiTaiApp/htmlFirst/checkPass.html User-Agent = Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.119 Safari/537.36 HBuilderX Headers:--------------- host=192.168.2.73 port=80 path=checkPhone.htm HttpMethod=POST poststring={"phone":"12345678900"} url=http://192.168.2.73/checkPhone.htm getValues:--------------- postValues:--------------- |
-- 作者:chenjiu6202 -- 发布时间:2022/3/15 9:13:00 -- Accept = */* (应该是 application/json) HttpMethod=OPTIONS (应该是 POST) 这两个有问题
|
-- 作者:有点蓝 -- 发布时间:2022/3/15 9:17:00 -- 这个要自行研究mui的开发文档了,建议咨询一下他们客服 |
-- 作者:ycs5801 -- 发布时间:2023/2/25 23:07:00 -- 后来解决了吗? |