I have the following:
<script type="text/javascript" src="jquery.js"></script>
<script>
$.ajax({
'async': true,
'type': "get",
'url': "service.php",
'crossDomain': true,
'dataType': 'json',
'success': function (response) {
if (response.result && response.result == "success") {
if (response.data) {
console.log("Found data: " + response.data);
}
else {
console.log("Unable to find data");
}
}
else {
console.log("Unknown error: " +
(response.error ? response.error : ""));
}
},
'error': function (response) {
console.log("Error : " + JSON.stringify(response));
}
});
</script>
Inside the service.php file is the the following:
<?php
$data = array("name" => "John Doe", "state" => "Somewhere","city" =>
"Someplace","zip" => "Somezip");
echo json_encode(array("result" => "success", "data" => $data));
?>
I need to change the code so instead of logging to the console it displays the data in the array in an HTML table. I am new to this and my coworkers and I have been challenged with attempting to figure this out for fun. We are all stuck as none of us use AJAX or JQUERY in our work. I have tried searching for an answer but I don't know enough about it to even know what to search for.