I have to move a system from one server to another, and I’m coming across an error when trying to access this page. The code is exactly the same as the live, working system, yet it doesn’t work now for some reason.
JS Code that pulls up the error:
var loadData = function(data) {
if(data)
data += '&offset=' + offset;
else
data = 'offset=' + offset;
var callback = {
success: function(o) {
try {
var data = YAHOO.lang.JSON.parse(o.responseText);
} catch(e) { alert('e: ' + e + '\no: ' + o + '\ndata: ' + data + '\noffset: ' + offset + '\n Response Text:' + o.responseText); }
// removed a lot of pointless code (no error here)
}
YAHOO.util.Connect.asyncRequest('POST', 'json/dmrlist.php', callback, data);
}
This is printed out from the alert:

This is the (start of) the php code that it is “calling”, yet there is an error as seen on the screenshot.
line 6: $JSON = json_decode($_POST['JSON']);
line 8: if($JSON->Depot)
line 9: $filter = " AND `Site` = '" . $JSON->Depot . "'";
Basically, $JSON is undefined, which means nothing is posted, but it looks like the javascript is meant to be posting the information to it?
I’m so confused, I have no experience with JSON or javascript, and can’t figure out why this won’t work.
The data variable is going to be sent to the server, but probably just as key/value pairs. You can try dumping them out like:
Or just
print_r( $_POST );
I suspect that $_POST[‘JSON’] is not set and you probably don’t need to decode the other values as JSON as they are probably just key/value pairs that you can read straight from the $_POST array, but I’m not familiar with YUI’s ajax functions so I could be wrong – check the values on the server.
P.S. Using the print_r this way will result in invalid return (it won’t be JSON), but you will be able to look at it in Firebug, etc. and see the values.