I did this:
$.ajax({
url: 'database.php',
dataType: 'json',
success: function(data, textStatus, jqXHR) {
//console.log(textStatus);
//console.log(jqXHR);
},
error: function(jqXHR, textStatus, errorThrown) {
console.log(jqXHR);
}
});
And i get a huge error which is kinda hard to understand what its saying.
abort: function (e){var t=e||w;return u&&u.abort(t),k(0,t),this}
always: function (){return i.done(arguments).fail(arguments),this}
complete: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
done: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
error: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
fail: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
getAllResponseHeaders: function (){return 2===b?a:null}
getResponseHeader: function (e){var t;if(2===b){if(!c){c={};while(t=Tn.exec(a))c[t[1].toLowerCase()]=t[2]}t=c[e.toLowerCase()]}return null==t?null:t}
overrideMimeType: function (e){return b||(p.mimeType=e),this}
pipe: function (){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()}
progress: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
promise: function (e){return null!=e?x.extend(e,r):r}
readyState: 4
responseText: "array(2) {↵ [0]=>↵ array(5) {↵ ["id"]=>↵ string(1) "0"↵ ["q"]=>↵ string(7) "Moskva?"↵ ["a"]=>↵ string(12) "Vid punkten!"↵ ["coordx"]=>↵ string(2) "25"↵ ["coordy"]=>↵ string(3) "255"↵ }↵ [1]=>↵ array(5) {↵ ["id"]=>↵ string(1) "1"↵ ["q"]=>↵ string(15) "Var ligger Rom?"↵ ["a"]=>↵ string(4) "D�r!"↵ ["coordx"]=>↵ string(3) "255"↵ ["coordy"]=>↵ string(3) "255"↵ }↵}↵"
setRequestHeader: function (e,t){var n=e.toLowerCase();return b||(e=v[n]=v[n]||e,y[e]=t),this}
state: function (){return n}
status: 200
statusCode: function (e){var t;if(e)if(2>b)for(t in e)m[t]=[m[t],e[t]];else C.always(e[C.status]);return this}
statusText: "OK"
success: function (){if(l){var t=l.length;(function i(t){x.each(t,function(t,n){var r=x.type(n);"function"===r?e.unique&&p.has(n)||l.push(n):n&&n.length&&"string"!==r&&i(n)})})(arguments),n?o=l.length:r&&(s=t,c(r))}return this}
then: function (){var e=arguments;return x.Deferred(function(n){x.each(t,function(t,o){var a=o[0],s=x.isFunction(e[t])&&e[t];i[o[1]](function(){var e=s&&s.apply(this,arguments);e&&x.isFunction(e.promise)?e.promise().done(n.resolve).fail(n.reject).progress(n.notify):n[a+"With"](this===r?n.promise():this,s?[e]:arguments)})}),e=null}).promise()}
In the phpfile:
I did remove var_dump($user)
I did change JSON to send the entire array
My var_dump looks like this:
array(2) {
[0]=>
array(5) {
["id"]=>
string(1) "0"
["q"]=>
string(7) "Moskva?"
["a"]=>
string(12) "Vid punkten!"
["coordx"]=>
string(2) "25"
["coordy"]=>
string(3) "255"
}
[1]=>
array(5) {
["id"]=>
string(1) "1"
["q"]=>
string(15) "Var ligger Rom?"
["a"]=>
string(4) "Där!"
["coordx"]=>
string(3) "255"
["coordy"]=>
string(3) "255"
}
}
Any ideas?
$user[0]
, which is one row, which is a one-dimensional array. – Barmar 23 hours agovar_dump()
out of the script. It will be read by$.getJSON
, but it's not valid JSON. – Barmar 23 hours ago