我有一个执行此操作的 php 文件:
$recresults = array('dupes' => $result, 'total' => $number2);
header('Content-type: application/json');
echo json_encode($recresults);
然后我将文件修改为:
$recresults = array('dupes' => $result, 'total' => $number2, 'thefield' => "WWW");
header('Content-type: application/json');
echo json_encode($recresults);
但是当我检查谷歌开发工具,网络选项卡时,我发现它没有返回我添加的最后一个数组元素
thefield
.如果我尝试在我的 JavaScript 中使用该元素的变量,我会得到 undefined data.thefield
.因此,为了查看服务器是否正在确认更改,我尝试将代码更改为:
$recresults = array('dupes' => $result, 'total' => $number2, 'thefield' => "WWW");
echo ("WTF SERVER?");
我还删除了类型
json
在我的 ajax 通话中。好吧,在检查了我关于服务器不承认我对 php 文件的更改是正确的。返回码仍然是 json
从第一个代码集。我尝试了一个更改 php 文件名的老技巧。不工作。尝试重新启动服务器。没有骰子。我能做些什么?服务器没有返回任何错误。
$.post(PROCESSORFILE, {"task": "csv_dedupe", "file_name": file_name, "column_dedupe": elem}, function(data) {
$("#message").replaceWith('<div id="message" class="nNote nSuccess hideit"><p><strong>CSV Deduped! </strong><span class="badge badge-important">' + data.thefield + '</span> duplicate<span class="label label-info"> ' + data.dupes+ '</span> found</p></div>')
});
当我使用 json_encode 从 php 文件返回内容时,我更改了上面的 JS
$.post()
输入 json
.
最佳答案
尝试以下操作,替换 ?
与 &
取决于您的PROCESSORFILE
的内容多变的。
var cacheBuster = new Date().getTime() + Math.round(Math.random()*100000);
$.post(PROCESSORFILE + "?t=" + cacheBuster, {"task": "csv_dedupe", "file_name": file_name, "column_dedupe": elem}, function(data) {
$("#message").replaceWith('<div id="message" class="nNote nSuccess hideit"><p><strong>CSV Deduped! </strong><span class="badge badge-important">' + data.thefield + '</span> duplicate<span class="label label-info"> ' + data.dupes+ '</span> found</p></div>')
});
这是缓存破坏代码,以确保检索到 php 页面的新副本。
关于php - 服务器停止确认 php 更改,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12366866/