PHP 使用jQuery查询跨域AJAX

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PHP 使用jQuery查询跨域AJAX相关的知识,希望对你有一定的参考价值。

<?php
// Set your return content type
header('Content-type: application/xml');

// Website url to open
$daurl = 'http://feeds.feedburner.com/jQueryHowto';

// Get that website's content
$handle = fopen($daurl, "r");

// If there is something, read and return
if ($handle) {
    while (!feof($handle)) {
        $buffer = fgets($handle, 4096);
        echo $buffer;
    }
    fclose($handle);
}
?>

// I named the file proxy.php and made my AJAX request to this url. Here is a jQuery code example:

<script>
$("#rssFeeds").load("path/to/proxy.php", function(){
  // Some callback functions
});
</script>

以上是关于PHP 使用jQuery查询跨域AJAX的主要内容,如果未能解决你的问题,请参考以下文章