I'm trying to get a JSON encoded object from a PHP file via AJAX GET using jQuery. I'm not exactly sure what's wrong. Here's my request in Javascript:
function getInfo()
{
$.ajax({
url:'ajax/ipGet.php',
type: 'GET',
dataType:'json',
success:function(response){
console.log(response);
}
});
}
ajax/ipGet.php
<?php
include 'dbcon.php';
class ipInfo {
private $ipAddress;
private $status;
private $serialNumber;
}
$ipInfo = new ipInfo;
$ipInfo->$ipAddress = "IP ADDRESS";
$ipInfo->$status = "ONLINE";
$ipInfo->$serialNumber = "TEST";
echo json_encode($ipInfo);
?>
I used GET because the user doesn't need to be redirected eventually. The PHP file will eventually retrieve values from a database.