My following javascript code doesn't working and return the following message :
parsererror
resources.php should return the following :{"cpu":"1.12"}
resources.php file contains :
<?php $load = sys_getloadavg(); echo '{"cpu":"'.json_encode($load[0]).'"}'; ?>
Javascript code :
$.ajax({
url : 'resources.php', //Target URL for JSON file
contentType: 'application/json; charset=utf-8',
type: 'GET',
dataType: 'json',
async : false,
success : function(data){
console.log(data);
},
error : function(xhr, status){
console.log(status);
alert(status);
}
});