我在一个script中写了这么一句话$.post("../common/toSession.php",{query:"123"});
但是在tosession.php文件中我用$_POST['query']得不到‘123’这个值     为啥啊?

解决方案 »

  1.   

    那我想知道  你是怎么知道得不到123这个值的呢?在tosession.php页面echo $_POST['query']script中$.post("../common/toSession.php",{query:"123"},function(x){
      alert(x);
    });
      

  2.   

    楼主alert得到是什么?{query:"123"}这个不是json?
      

  3.   

    {"query":"123"}
      

  4.   

    6楼 +1 注意引号问题。另外检查一下文件路径。
    不行的话FIREBUG检查一下。
      

  5.   

    function generateQueryExcel2(form) {        
            var str ='';   
            var cookie ='';
            var joinction ='';
            var myquery ='';
            var whereclose = '';
            $(".filterExcelcheck:checked").each(function() {
              str = str+ ' '+$(this).val()+' as '+$(this).val().replace('.','_')+' ,';
              cookie = cookie+ ' c'+$(this).val()+'l';
            });  
            $.cookie("exportExcel", null);
            $.cookie("exportExcel", cookie , {expires: 30, domain: '127.0.0.1'});
           
            //extract the last char ','
            str = str.slice(0,-1)
            // if dwo. existing
            if( str.indexOf('dwo.') >-1 ) joinction = "LEFT JOIN lte_dct_cr.cridetails cri ON cr.CR_Id = cri.CR_Id LEFT JOIN lte_dct_cr.DWOdetails dwo ON cri.CRI_Id = dwo.CRI_Id";
            //else if "cri." existing
            else if(str.indexOf('cri.')>-1) joinction = "LEFT JOIN lte_dct_cr.cridetails cri ON cr.CR_Id = cri.CR_Id";
            whereclose = form.whereclose.value;
            myquery = "SELECT"+str+"FROM lte_dct_cr.crdetails cr "+joinction+" "+whereclose;
            $.post("../common/toSession.php",{query:"123"});
             $('.toExcel').html("<iframe height=0 width=0 src='../common/excel_CRExport.php' name='excel'>"+myquery+"</iframe>");
            
    }
    这个是完整的function, 就是用post传值到后台  可是就是没有用哦  路径我也写对的哦  是不是要啥插件?