首页 > 微信公众号,前台向后台发起ajax请求,后台获取不到发送过来的值是怎么回事??

微信公众号,前台向后台发起ajax请求,后台获取不到发送过来的值是怎么回事??

Ecshop后台:
微信公众号前台:

try{
    function getData(method,path,searchStr,dataType,fn){
      var xhr=new XMLHttpRequest();
      method=method.toUpperCase();
          xhr.open(method.toLowerCase(),(method==='POST') ? path : path+'?'+searchStr,true);
          if (method==='POST'){
            xhr.setRequestHeader('content-type','application/x-www-form-urlencoded');
          }
          xhr.send((method==='POST') ? searchStr : null);
          xhr.onreadystatechange=function(){
            if (this.readyState===4 && this.status===200){
              var data=this.responseText;
             
              alert('fanyingshuju: '+data);
            }
          }
    }
    getData('GET','goods.php','act=price&id=' + goodsId + '&attr=' + attr + '&number=' + qty, changePriceResponse);
    
  }catch(err){
    alert('error: '+err);
  }
  

后台:

 die('发起的请求: '.$_REQUEST['act']);

这个地方总是获取不到值,究竟是怎么回事??


考虑是否跨域了

【热门文章】
【热门文章】