I had a php file that did this:
$recresults = array('dupes' => $result, 'total' => $number2);
header('Content-type: application/json');
echo json_encode($recresults);
Then I modified the file to this:
$recresults = array('dupes' => $result, 'total' => $number2, 'thefield' => "WWW");
header('Content-type: application/json');
echo json_encode($recresults);
But when I checked google dev tools, network tab, I seen that it was not returning the last array element that I added thefield. If I attempt to use the variable for that element in my JavaScript I get undefined data.thefield.
So to see if changes were being being acknowledged by the server at all I tried changing my code to this:
$recresults = array('dupes' => $result, 'total' => $number2, 'thefield' => "WWW");
echo ("WTF SERVER?");
I also deleted type json on my ajax call. Well after checking I was right about the server not acknowledging my changes to the php file. The return code was still the json from the first code set. I tried an old trick of changing the php file’s name. Did not work. Tried rebooting server. No dice.
What can I do? The server is not returning any errors.
$.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>')
});
When I return stuff from the php file using json_encode I change the above JS $.post() to type json.
Try the following, replacing
?with&depending on the content of yourPROCESSORFILEvariable.This is cache-buster code, to ensure a fresh copy of the php page is retrieved.