开发者

How to use JQuery AJAX with Cloud9 IDE?

I'm usi开发者_开发百科ng Cloud9 IDE. My goal is to be able to develop applications that use JQuery AJAX.

I have these 2 files:

  1. test.htm

<p class="result">the result</p>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
    <script>
$.get('test.php', function(data) {
  $('.result').html(data);
  alert('Load was performed.');
});
</script>

`2. test.php

<?php echo "hello world"; ?>

The problem is that the paragarph with class "result" should read "hello world". Instead, the entire contents of the php file are being added.

How do I get the php file to just echo "hello world" as expected?


You are not able to run PHP scripts in Cloud9IDE. This possibility will be implemented in the future.


Your php code needs to be wrapped with these tags:

<?php echo "Hello world";?>


You need to wrap the php code in php open/close tags

<?php
 echo "hello world";
?>


You need to call your .php script from a web server with PHP installed for it to be executed, and it needs to be wrapped in <?php /*code*/ ?>

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜