我有一个非常简单的hello world ajax-php示例,它返回整个php脚本。这是代码:
$.ajax({
type: "GET",
contentType: "text",
url: "hello-world.php",
success: function(data){
$("#myDiv").text(data);
console.log(data);
}
});
<?php
// A simple web site in Cloud9 that runs through Apache
// Press the 'Run' button on the top to start the web server,
// then click the URL that is emitted to the Output tab of the console
echo 'Hello world!';
?>
<?php
// A simple web site in Cloud9 that runs through Apache
// Press the 'Run' button on the top to start the web server,
// then click the URL that is emitted to the Output tab of the console
echo 'Hello world!';
?>
谢谢!
答案 0 :(得分:2)
根据@DavidRiccitelli - 看起来你没有运行php而apache只是提供文件而不是传递给PHP来执行。
答案 1 :(得分:0)
有可能您的PHP未被解释,因此将作为原始HTML返回。