代码之家  ›  专栏  ›  技术社区  ›  Jim G.

IIS正在阻止我的回拨吗?

  •  0
  • Jim G.  · 技术社区  · 15 年前
    • 当我在卡西尼号尝试下面的代码时,我得到了一个有效的响应。
    • 当我在浏览器中进行以下RESTful调用时,我看到一个有效的响应- http://api.brightcove.com/services/library?command=find_all_videos&page_size=1&video_fields=name&token=[token] .
    • 但当我在IIS 7.5中托管我的网站时,回调函数会收到 null 争论。

    我的问题是:

    IIS 7.5是否可以阻止 回应?


    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            function validateReadToken() {
                $.getJSON("http://api.brightcove.com/services/library?command=find_all_videos&page_size=1&video_fields=name&token=[token]",
                    function (data) {
                        alert(data.items.length);
                    }
                );
            }
    
            $(document).ready(function () {
                $("a").click(function (event) {
                    validateReadToken();
                });
            });    
        </script>
    </head>
    <body>
        <a href="javascript:void(0)">Test</a>
    </body>
    </html>
    
    2 回复  |  直到 15 年前
        1
  •  1
  •   Dan Kendall    15 年前

    或许值得一读: http://support.brightcove.com/en/docs/using-xmlhttp-make-calls-proxy .

    我不是AJAX专家,但是我会把你的站点托管在你自己的IIS服务器上,然后对brightcove发出服务请求,这似乎是跨域问题的保护伞。

    也许尝试服务器端代理是前进的方向。

    干杯, 丹

        2
  •  0
  •   Jim G.    15 年前

    谢谢大家的帮助。

    事实上,我需要注意我试图提出跨域请求的事实。

    为了绕过这个限制,我需要使用JSONP。


    新代码:

    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <script src="http://code.jquery.com/jquery-1.4.2.min.js" type="text/javascript"></script>
        <script type="text/javascript">
            function validateReadToken() {
                var url = 'http://api.brightcove.com/services/library?command=find_all_videos&page_size=1&video_fields=name&token=[token]';
                $.getJSON(url + "&callback=?", function (data) {
                    alert(data.items.length);
                });
            }
    
            $(document).ready(function () {
                $("a").click(function (event) {
                    validateReadToken();
                });
            });    
        </script>
    </head>
    <body>
        <a href="javascript:void(0)">Test</a>
    </body>
    </html>