dortmundbvb0624 2013-06-22 23:04
浏览 34
已采纳

使用AJAX发布到PHP - 返回完整的PHP页面[重复]

This question already has an answer here:

The issue I'm having is that when I'm attempting to post to a PHP page it will just return the entire PHP document and not the things being echoed.

 <script type="text/javascript">
    $.ajax({ type:"POST",
             url:"backMap/locationCreation.php",
             data: { name: "TEMP" },
             success: function(data) { $("#awesomet").html(data);},
             error: function(xhr, textStatus, thrownError, data) {
                alert("Error: " + thrownError); 
             }
    });
 </script>
 <div id="awesomet">Not showing.</div>

With this I am trying to send an Ajax Post to the given URL. I am giving it some data and if it returns successfully then it will put it's data within the div.

 <?php
   if (isset($_GET['name'])) {
       echo "Asked for name!";
   }
   for ($i = 1; $i <= 10; $i++) {
      echo '<p>For loop! Value: ' . $i . ' of 10.</p>';
   }
 ?>

When I call this I receive the entire php page as a result.

I literally get the whole page, if statements, for loop and all. Including the <?php flags. I don't understand why I'm receiving the data like this.

I am running this through Phonegap.

Any help is appreciated.

</div>
  • 写回答

2条回答 默认 最新

  • dronthpi05943 2013-06-22 23:22
    关注

    If you see the entire php file including the PHP declaration, this might point to a problem with your webserver configuration. Maybe your webserver does not recognize files ending on .php as PHP files.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 求差集那个函数有问题,有无佬可以解决
  • ¥15 【提问】基于Invest的水源涵养
  • ¥20 微信网友居然可以通过vx号找到我绑的手机号
  • ¥15 寻一个支付宝扫码远程授权登录的软件助手app
  • ¥15 解riccati方程组
  • ¥15 display:none;样式在嵌套结构中的已设置了display样式的元素上不起作用?
  • ¥15 使用rabbitMQ 消息队列作为url源进行多线程爬取时,总有几个url没有处理的问题。
  • ¥15 Ubuntu在安装序列比对软件STAR时出现报错如何解决
  • ¥50 树莓派安卓APK系统签名
  • ¥65 汇编语言除法溢出问题