我有一个返回结果,整个PHP脚本一个非常简单的Hello World Ajax的PHP的例子。这里的code:
I have a very simple hello world ajax-php example that returns as a result the whole php script. here's the code:
$.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!';
?>
谢谢!
那么你的PHP是不是跨preTED,因而被返回原始的HTML。
Chances are your PHP isn't being interpreted, and thus is being returned as raw HTML.
检查here对于类似的问题。