Home  >  Article  >  Backend Development  >  How to force wx.request request results not to use cache?

How to force wx.request request results not to use cache?

WBOY
WBOYOriginal
2016-10-10 11:56:111295browse

<code> wx.request({
  url: 'wxapp.php',
  data: {
     x: '12' ,
     y: '34'
  },
  header: {
      'Content-Type': 'application/json'
  },
  success: function(res) {
    console.log(res.data)
  }
})
</code>

php:

<code><?php
$x=$_GET['x'];
$y=$_GET['y'];
$z=['x'=>$x,'y'=>$y];
echo json_encode($z);</code>

Dang

<code>      data: {
         x: '12' ,
         y: '34'
      }</code>

Return

<code>1234</code>

Dang

<code>      data: {
         x: '123' ,
         y: '343'
      }</code>

Return

<code>Object {x: "123", y: "343"}</code>

Modified again

<code>      data: {
         x: '12' ,
         y: '34'
      }</code>

Compile, clear cache, restart
Return

<code>1234</code>

What is this situation?

Reply content:

<code> wx.request({
  url: 'wxapp.php',
  data: {
     x: '12' ,
     y: '34'
  },
  header: {
      'Content-Type': 'application/json'
  },
  success: function(res) {
    console.log(res.data)
  }
})
</code>

php:

<code><?php
$x=$_GET['x'];
$y=$_GET['y'];
$z=['x'=>$x,'y'=>$y];
echo json_encode($z);</code>

Dang

<code>      data: {
         x: '12' ,
         y: '34'
      }</code>

Return

<code>1234</code>

Dang

<code>      data: {
         x: '123' ,
         y: '343'
      }</code>

Return

<code>Object {x: "123", y: "343"}</code>

Modified again

<code>      data: {
         x: '12' ,
         y: '34'
      }</code>

Compile, clear cache, restart
Return

<code>1234</code>

What is this situation?

<code>wx.request({
  url: 'wxapp.php',
  data: {
     x: '12',
     y: '34',
     _: (new Date()).getTime()  //加个随机参数
  },
  header: {
      'Content-Type': 'application/json'
  },
  success: function(res) {
    console.log(res.data)
  }
});</code>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn