I have the following problem. I use this function for server communication (js):
function serverComm(name,urlpath,args,callback){
var url = urlpath + "/" + name + ".php";
jQuery.ajax({
type: "POST",
url: url,
dataType: 'json',
data: {functionname: name, args: args},
success: function (obj) {
window[callback](obj);
},
error: function(xhr, status, error) {
var obj = {error : "AJAX Error: " + error};
console.log('XHR ' + xhr.responseText + " Status " + status);
window[callback](obj);
}
});
}
I've developed an entire webpage in my own local server. ON the server side I do whole bunch of queries and return the results as associative arrays by using the function:
echo json_encode($ret);
Where ret is the structure I've formed.
Now, I do a dump of all the tables that I use in the server and load them up in my own personal database.
On my personal server everything works perfectly.
But in a couple of pages of the actual web server, a couple of pages show blank because I get this error:
AJAX Error: SyntaxError: Unexpected end of JSON input
When I look at what the console printed, it prints this:
XHR
Status parsererror
Now the ONLY thing I can think of that might be a problem is the fact that several names returned have spanish caracters (like ñ and ó).
But it works perfectly well in my own DB and I don't know the difference or how to make them behave both equally.
My own DB is MariaDB while the server uses Mysql 5.7 (its an EC2 intance from AWS). The tables in both were created from the same script (This is why have tagged the question with all three tags, SQL, PHP and Javascript)
Can anyone tell me how can I know why the receiver can't parse the JSON input? Or provide a guess as to how I can go about fixing this?