javascript - weex POST request web-side body server cannot obtain parameters
世界只因有你
世界只因有你 2017-07-05 11:05:14
0
2
1528

The POST request server cannot get the parameters. It is found that Stream.fetch uses the method of directly turning the body into a string and passing it to the server. Our server requires an Ajax request (&key=value) like Jquery. The parameter intercepted by Charles is the key value in the request, but the keyValue style is obtained in jquery. In which file should I modify the method of submitting the 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;
  });
世界只因有你
世界只因有你

reply all(2)
扔个三星炸死你

Add "Content-Type": 'application/x-www-form-urlencoded; to the request header

女神的闺蜜爱上我

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;
  });
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!