gpt4 book ai didi

php - 防止在 ajax 请求上执行整个 php

转载 作者:行者123 更新时间:2023-11-30 08:17:06 24 4
gpt4 key购买 nike

我有一个 ajax 脚本 (jquery),它要求 index.php 输出生成的变量。这个 index.php 也是生成整个页面并初始填充数据的文件。当 ajax 请求此文件时,如何只让 getNewData() 函数。现在它复制整个页面并输出它,所以所有的东西都有两个。

最佳答案

    function isAjax() {
return env('HTTP_X_REQUESTED_WITH') === "XMLHttpRequest";
}

试试这个...来自 CakePHP

关于php - 防止在 ajax 请求上执行整个 php,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1309197/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com