ajax查询时,用’IS_AJAX‘判断不了

迅睿框架 更新 2022-12-06 22:44:37 传播易


 if(IS_POST){

            

            $post = \Phpcmf\Service::L('input')->post('data');

            

            if(IS_AJAX){

                

                $post['stime'] = \Phpcmf\Service::L('input')->post('stime');

                $post['etime'] = \Phpcmf\Service::L('input')->post('etime');


            }else{


                $post['stime'] = strtotime($post['stime']);

                $post['etime'] = strtotime($post['etime']) + 86399;

            }

}


企业微信截图_20221205142955

查询按钮是用’IS_POST‘来判断,查询是没有问题的。导出用的是’ajax‘提交查询,代码如上,’IS_AJAX‘这里进不来,这是为什么呢?

 if(IS_POST){

            

            $post = \Phpcmf\Service::L('input')->post('data');

            

            if(IS_AJAX){

                

                $post['stime'] = \Phpcmf\Service::L('input')->post('stime');

                $post['etime'] = \Phpcmf\Service::L('input')->post('etime');


            }else{


                $post['stime'] = strtotime($post['stime']);

                $post['etime'] = strtotime($post['etime']) + 86399;

            }

}

方案

  • 对方正在输入 #1 · 2022-12-05 14:39:39
    查检查是get还是post了
  • 传播易 #2 · 2022-12-05 14:50:49
    对方正在输入 <script type="text/javascript"> function dr_toword(fid,stime,etime){ $.ajax({ url: location.href, type: "post", dataType: "json", data: { womfile:fid, stime:stime, etime:etime, t1:myChart_1.getDataURL(), t2:myChart_2.getDataURL(), t3:myChart_3.getDataURL(), t4:myChart_4.getDataURL(), t5:myChart_5.getDataURL(), t6:myChart_6.getDataURL(), t7:myChart_7.getDataURL(), csrf_test_name: "5a26548e8aa8d6fbe533fa7bd0ea10c0" }, success: function (data) { if(data.status == 1){ window.open('/womdown-week-26.html', '_self'); }else{ dr_cmf_tips(1,"操作失败,请稍后重试"); } } }); }</script>导出的方法是这样的
  • 匿名者 #3 · 2022-12-05 15:53:33
    IS_AJAX 是从何来的?条件不合理呀
  • 亿友 #4 · 2022-12-06 22:43:16
    你打印出一般情况下$_SERVER['HTTP_X_REQUESTED_WITH']默认是XMLHttpRequest所有你打印出来看下。
    $_SERVER['HTTP_X_REQUESTED_WITH']) === 'xmlhttprequest'
    感觉你这个分开应该在在加个传递数据,比如action,导出是什么值然后判断。
  • 亿友 #5 · 2022-12-06 22:44:37
    亿友 打印出IS_AJAX看下。点导出的后看下。

迅睿系统漏洞

站群分站系统
站群分站系统(2026-10-15)
子站域名新增llms.txt访问
GEO系统
GEO系统(2026-10-14)
修复下载zip空白地址问题 修复流量复刻和任务队列错误
GeoSeo收录宝
GeoSeo收录宝(2026-10-14)
新增 站长工具箱 前端首页自动调用meta 数据
滑块验证码 Gocaptcha
滑块验证码 Gocaptcha(2026-10-13)
基于开源项目 go-captcha 的行为验证码插件,滑动拼图、区域...
GeoSeo工具箱
GeoSeo工具箱(2026-10-13)
优化巡检任务
GeoSeo排名助手
GeoSeo排名助手(2026-10-11)
加入大模型自定义
SEO聚合关键字
SEO聚合关键字(2026-10-11)
优化关键字列表页最多支持1万篇文章,过多会导致服务器扛不住;
CMS内容同步复制
CMS内容同步复制(2026-10-10)
增加时间是否更新的开关