Use jQuery.getJSONinstead .getif you want your JSON to be parsed. Also, make sure the jQuery library is loaded correctly.
function clickHere(){
$.getJSON("index.php", function(data) {
alert(data.user);
});
}
You are currently using $.get(url, function(data){...}). In this context data, this is the line containing the response from the server:
{"user":"Robin098","id":"80465"}
Using alert(data)inside the function, you will see this line.
source
share