久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

javascript - weex POST請求web端body服務器獲取不到參數

瀏覽:110日期:2023-02-16 13:03:10

問題描述

POST請求服務器取不到參數,發現Stream.fetch采用的是直接將body變成字符串專遞給服務器,而我們的服務器需要的像Jquery那個樣的Ajax請求(&key=value)的形式,在charles攔截的到參數在request中為key值,而jquery中得到的是keyValue樣式,請問在哪個文件里面修改提交body的方式?

stream.fetch({

method: ’POST’, url: POST_URL, type:’json’,

//headers: {’Content-Type’: ’application/json; charset=utf-8’,},

body: JSON.stringify({ data: bodyString})//or you can just use JSON Object {username:’weex’} }, function(ret) { if(!ret.ok){ me.postResult = 'request failed'; }else{ console.log(’get:’+JSON.stringify(ret)); me.postResult = JSON.stringify(ret.data); } },function(response){ console.log(’get in progress:’+response.length); me.postResult = 'bytes received:'+response.length; });

問題解答

回答1:

在請求頭中加入 'Content-Type': ’application/x-www-form-urlencoded;即可

回答2:

stream.fetch({

method: ’POST’, url: POST_URL, type:’json’, body:JSON.stringify({username:’weex’})//or you can just use JSON Object {username:’weex’} }, function(ret) { if(!ret.ok){ me.postResult = 'request failed'; }else{ console.log(’get:’+JSON.stringify(ret)); me.postResult = JSON.stringify(ret.data); } },function(response){ console.log(’get in progress:’+response.length); me.postResult = 'bytes received:'+response.length; });

標簽: JavaScript
相關文章:
主站蜘蛛池模板: 九龙坡区| 广丰县| 上蔡县| 蓬溪县| 青铜峡市| 西和县| 泰宁县| 砀山县| 阿克| 姚安县| 岳阳县| 新野县| 榆社县| 普兰县| 沅陵县| 邯郸市| 屏山县| 大悟县| 卓尼县| 通海县| 邹城市| 石河子市| 资阳市| 宁强县| 乌什县| 河南省| 南宁市| 西畴县| 广宁县| 安仁县| 蒙阴县| 双辽市| 塔河县| 大城县| 介休市| 泾阳县| 珠海市| 耿马| 禹城市| 怀仁县| 甘谷县|