通过AJAX通过PHP获取数据无法正常工作

时间:2015-11-14 17:59:15

标签: php ajax

我在使用通过PHP生成数据和使用ajax方法检索数据的组合从服务器获取数据时遇到问题。

我想通过调用get_data.php的receive.php中的GET获取数据

我的ajax函数位于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;

?>

当我运行receive.php时,我收到一个ajax错误:GET 404错误。

我错过了什么?

0 个答案:

没有答案
相关问题