从不同的php页面回显到div

时间:2012-01-08 22:44:31

标签: php javascript

我刚创建了一个应该从PHP文件中读取回声的函数。我认为这个功能正常,但似乎与我的php文件有关。

这是我的功能

function CallProverb(){
$.ajax({
type: "POST",
  url: "Example_RSS_Feed.php",
  data: paramas,
    success: function(responseText)
    {
    document.getElementById("ContentHolder").innerHTML = responseText;
    }
  }
);
}

我的PHP文件,它是带有数组的RSS源。

header("Content-Type: application/rss+xml; charset=UTF-8");  


        $rssFeed = '<?xml version="1.0" encoding="UTF-8"?>';
        $rssFeed .= '<rss version="2.0">';
        $rssFeed .= '<channel>';
        $rssFeed .= '<title>Example RSS feed</title>';
        $rssFeed .= '<link>http://localhost/Example_RSS_Feed.php</link>';
        $rssFeed .= '<description>This is an example RSS feed called for at ' . date("l n F") . '</description>';
        $rssFeed .= '<language>sv</language>';
        $rssFeed .= '<copyright>Created 2010 by Mikael Hasselmalm</copyright>';

        $rssFeed .= '<item>';
        $rssFeed .= '<title>Example feed</title>';
        $rssFeed .= '<description>';

        $rssFeed .= 'Exempel på ett RSS-flöde anropat ' . date("l n F");

        $rssFeed .= '</description>';
        $rssFeed .= '<link>LINK</link>';
        $rssFeed .= '<pubDate>' . date("l n F") . '</pubDate>';
        $rssFeed .= '</item>';

        $rssFeed .= '</channel>';
        $rssFeed .= '</rss>';

        $counter = array(1 => 'one.', ' two ', 'three ',);
       echo $counter[2];

所以它应该在我的内容持有者中输出两个,但我不能= /

1 个答案:

答案 0 :(得分:0)

您是否包含jQuery文件?

您可以尝试从PHP中删除HEAD信息并尝试。

删除此行:

header("Content-Type: application/rss+xml; charset=UTF-8");  

PHP标头可能会产生输出问题。