任何方式进行跨服务器的Ajax调用?方式、服务器、Ajax

2023-09-10 21:26:25 作者:比空白更空白的空白

我学习XML我发现一个网站,有一个XML饲料。我试图找出是否有一种方法来进行跨服务器的Ajax调用?

在code我现在用的就是如下:

 < HTML>
< HEAD>
  &所述;脚本的src =的http://$c$c.jquery.com/jquery-latest.js>&所述; /脚本>
< /头>
<身体GT;

<脚本>

$阿贾克斯({
    键入:GET,
    网址:http://www.nfl.com/liveupdate/scorestrip/ss.xml
    数据类型:XML,
    成功:函数(XML){
        //国米preT响应
        $(XM​​L).find('G')。每个(函数(){

            //例:显示在控制台中的XML标记
            执行console.log(本);

            //例:把一些输出的DOM
            $(#divOutput)追加($(本).attr(HNN))。

        });

        $(XM​​L).find('G')。每个(函数(){



            //例:把一些输出的DOM
            $(#divOutput)追加($(本).attr(K))。

        })

    }
});
< / SCRIPT>

< D​​IV ID =divOutput>< / DIV>

< /身体GT;
< / HTML>
 

解决方案

的唯一途径为你做跨域Ajax请求(即我所知道的)是:

使用 JSONP 使用代理 在一个相关的替代品,这可能是使用谷歌饲料API (或类似的服务) 如果服务器支持它(和你通常需要控制服务器),使用访问控制头

在这种情况下,它看起来像你不能做任何这些,所以你的运气了。

客户端调用服务器端方法 ASP.NET AJAX Atlas Anthem.NET和Ajax.NET Professional实现之小小比较

I am learning XML and I've found a website that has a XML feed. I am trying to figure out if there is a way to make cross server ajax calls?

The code I am using is below:

<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>

<script>

$.ajax({
    type: "GET",
    url: "http://www.nfl.com/liveupdate/scorestrip/ss.xml",
    dataType: "xml",
    success: function(xml) {
        // Interpret response
        $(xml).find('g').each(function() {

            // Example: Show the XML tag in the console
            console.log(this);

            // Example: Put some output in the DOM
            $("#divOutput").append($(this).attr("hnn"));

        });

        $(xml).find('g').each(function() {



            // Example: Put some output in the DOM
            $("#divOutput").append($(this).attr("k"));

        })        

    }
});
</script>

<div id="divOutput"></div>

</body>
</html>

解决方案

The only ways for you to make cross domain ajax requests (that I'm aware of) are:

Use JSONP Use a proxy A related alternative to this might be to use the Google Feed API (or similar service) If the server supports it (and you'll usually need to control the server), use access control headers

In this case, it looks like you can't do any of these, so you're out of luck.