亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

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

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

jeck貓 2018-10-05 12:07:11
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;  });
查看完整描述

2 回答

?
浮云間

TA貢獻1829條經驗 獲得超4個贊

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;

  });


查看完整回答
反對 回復 2018-10-21
?
犯罪嫌疑人X

TA貢獻2080條經驗 獲得超4個贊

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

查看完整回答
反對 回復 2018-10-21
  • 2 回答
  • 0 關注
  • 1023 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號