0

我需要的是一种方法来引入这个:184.173.18.228/api/profile/1000/0/Adam.Adams(这是一个xml文件)到php(我假设)在Joomla中使用(我可以使用Sourcerer Joomla 中的代码) - 我遇到的问题是存在跨域代理问题 - 上周末我能够使用 ajax/jquery 在我的机器上本地呈现该 xml:

// jQuery script

$(function() {
    // Load data from proxy.php using GET request
    $.get('test.xml', function(data)
    {
        // Search for the XML element you want, perform an action on each occurrence of found element
        $(data).find("XMLElement").each(function()
        {
            $('#output').append($(this).attr('XMLAttribute')); // Display desired attribute of element -OR-
            $('#output').append($(this).children("Phone").text());

我什至不确定我是否正确地问了这个问题 - 我想要发生的是:一个 php 脚本,用于引入该 xml/url 以在页面上回显/填充 html。我已经尝试了一百万件事,但就是无法得到它

4

1 回答 1

0

这真的看起来像 Javascript,而不是 php。在 php 中,你不会有跨域限制,因为它运行在服务器上,而不是浏览器上。

所有浏览器都会阻止跨域 ajax 调用。

您的解决方案是在 php 中编写一个脚本,该脚本对远程站点执行 wget 或 curl,因此您调用本地脚本并且服务器上的脚本加载远程 url。你应该可以找到一些现成的。

于 2013-01-27T22:58:51.700 回答