I am having problems getting data from a server using a combination of generating the data through PHP and using an ajax method to retrieve it.
I want to get the data through GET within receive.php that calls get_data.php
My ajax function located within receive.php:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type = "text/javascript">
$.ajax({
url: '<website>/get_data.php',
data: {
format: 'json'
},
error: function() {
$('#info').html('<p>An error has occurred</p>');
},
dataType: 'jsonp',
success: function(data) {
console.log(data);
},
type: 'GET'
});
</script>
get_data.php:
<?php
...
$data = array('a','b','c');
$data = json_encode($long);
echo $data;
?>
When I run receive.php I get an ajax error: GET 404 error.
What am I missing?