久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

      • <bdo id='hUzA6'></bdo><ul id='hUzA6'></ul>
      <i id='hUzA6'><tr id='hUzA6'><dt id='hUzA6'><q id='hUzA6'><span id='hUzA6'><b id='hUzA6'><form id='hUzA6'><ins id='hUzA6'></ins><ul id='hUzA6'></ul><sub id='hUzA6'></sub></form><legend id='hUzA6'></legend><bdo id='hUzA6'><pre id='hUzA6'><center id='hUzA6'></center></pre></bdo></b><th id='hUzA6'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='hUzA6'><tfoot id='hUzA6'></tfoot><dl id='hUzA6'><fieldset id='hUzA6'></fieldset></dl></div>

      <small id='hUzA6'></small><noframes id='hUzA6'>

      <tfoot id='hUzA6'></tfoot>

      <legend id='hUzA6'><style id='hUzA6'><dir id='hUzA6'><q id='hUzA6'></q></dir></style></legend>
      1. 跨域進行 JavaScript 調(diào)用

        Making JavaScript call across domains(跨域進行 JavaScript 調(diào)用)

        1. <i id='slLpv'><tr id='slLpv'><dt id='slLpv'><q id='slLpv'><span id='slLpv'><b id='slLpv'><form id='slLpv'><ins id='slLpv'></ins><ul id='slLpv'></ul><sub id='slLpv'></sub></form><legend id='slLpv'></legend><bdo id='slLpv'><pre id='slLpv'><center id='slLpv'></center></pre></bdo></b><th id='slLpv'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='slLpv'><tfoot id='slLpv'></tfoot><dl id='slLpv'><fieldset id='slLpv'></fieldset></dl></div>
        2. <tfoot id='slLpv'></tfoot>
            1. <legend id='slLpv'><style id='slLpv'><dir id='slLpv'><q id='slLpv'></q></dir></style></legend>

              <small id='slLpv'></small><noframes id='slLpv'>

                  <tbody id='slLpv'></tbody>

                  <bdo id='slLpv'></bdo><ul id='slLpv'></ul>
                  本文介紹了跨域進行 JavaScript 調(diào)用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧!

                  問題描述

                  這是目標:

                  移交引用遠程服務(wù)器上的 JavaScript 文件的腳本標記.該 JavaScript 文件應(yīng)返回 HTML,然后將顯示在調(diào)用 HTML 頁面上.

                  Hand off a script tag that references a JavaScript file on a remote server. That JavaScript file should return HTML that will then be displayed on the calling HTML page.

                  我嘗試通過兩種方式解決這個問題:

                  I've attempted to approach this in two ways:

                  首先,我嘗試在 JavaScript 中使用 XMLHttpRequest 來調(diào)用這個遠程服務(wù)器.在 IE 中,它會按預(yù)期工作,但 FF、Safari 和 Chrome 會返回一個空響應(yīng).我從研究中得到的總體反應(yīng)是,請求被阻止,因為它嘗試訪問的服務(wù)器與其運行的位置不同(都是本地主機,但端口不同).

                  First, I attempted to use XMLHttpRequest in JavaScript to call this remote server. In IE, it would work as expected but FF, Safari, and Chrome would return an empty response. The overall response I got from my research was that the request was being blocked since the server it's trying to access is different from where it's running (both localhost, but different ports).

                  其次,我研究了 Google Gadgets 之類的東西是如何工作的,因為它們有效地為您提供了一個引用外部 JavaScript 的簡單腳本標記.據(jù)我所知,似乎有某種 iframe 操作僅通過使用的基本 url 進行(下面的示例).這似乎是要走的路,即使使用 iframe 不是我最初的想法.我猜 Google 代碼會將 iframe 作為 HTML 返回到嵌入了此腳本的 HTML 文件.

                  Second, I looked at how things like Google Gadgets work as they effectively give you a simple script tag that's referencing external JavaScript. From what I can gather, it appears that there's some sort of iframe action going on simply by the base url being used (example below). This appears to be the way to go, even though using an iframe wasn't my initial thought. I'm guessing the Google code is returning an iframe as HTML to the HTML file that has this script embedded.

                  關(guān)于我應(yīng)該如何進行的任何建議?

                  Any suggestion on how I should proceed?

                  <script src="http://www.gmodules.com/ig/ifr?url=http://ralph.feedback.googlepages.com/googlecalendarviewer.xml&amp;synd=open&amp;w=320&amp;h=200&amp;title=&amp;border=%23ffffff%7C3px%2C1px+solid+%23999999&amp;output=js"></script>
                  

                  推薦答案

                  JSONP是處理同源策略的一種非常常見的方式.由于大多數(shù) javascript 框架(例如 jquery)已經(jīng)支持它,因此您無需了解技術(shù)細節(jié)即可使用它.
                  您也可以通過從 javascript 構(gòu)造 script 標記(如您所提到的)來自己完成這個技巧.谷歌分析代碼片段就是這種方法的一個例子:

                  JSONP is a very common way to deal with same origin policy. Since most javascript frameworks (e.g., jquery) already support it, you don't have to get into technical details to use it.
                  You can also do the trick yourself by constructing script tag from javascript (as you mentioned). Google Analytics code snippet is an example of such approach:

                        var ga = document.createElement('script');
                        ga.type = 'text/javascript';
                        ga.async = true;
                        ga.src = 'url here';
                        var s = document.getElementsByTagName('script')[0];
                        s.parentNode.insertBefore(ga, s);
                  

                  至于 iframe 的想法(如果我理解你的話),它是行不通的.您可以在頁面上使用 iframe 元素來顯示來自另一臺服務(wù)器的內(nèi)容,但瀏覽器不允許您使用 javascript 從主頁訪問它.

                  As for iframe idea (if I understand you currectly), it's not gonna work. You can use iframe element on your page to display content from another server, but browser won't let you access it from main page using javascript.

                  編輯
                  這個原始提案詳細介紹了 JSONP 的用法:
                  http://bob.pythonmac.org/archives/2005/12/05/remote-json-jsonp/

                  這篇關(guān)于跨域進行 JavaScript 調(diào)用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

                  【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權(quán)益,請聯(lián)系我們刪除處理,感謝您的支持!

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調(diào)用完成)
                  JavaScript innerHTML is not working for IE?(JavaScript innerHTML 不適用于 IE?)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  • <small id='viyHs'></small><noframes id='viyHs'>

                        <tbody id='viyHs'></tbody>

                      <i id='viyHs'><tr id='viyHs'><dt id='viyHs'><q id='viyHs'><span id='viyHs'><b id='viyHs'><form id='viyHs'><ins id='viyHs'></ins><ul id='viyHs'></ul><sub id='viyHs'></sub></form><legend id='viyHs'></legend><bdo id='viyHs'><pre id='viyHs'><center id='viyHs'></center></pre></bdo></b><th id='viyHs'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='viyHs'><tfoot id='viyHs'></tfoot><dl id='viyHs'><fieldset id='viyHs'></fieldset></dl></div>

                      1. <tfoot id='viyHs'></tfoot>
                          <bdo id='viyHs'></bdo><ul id='viyHs'></ul>
                            <legend id='viyHs'><style id='viyHs'><dir id='viyHs'><q id='viyHs'></q></dir></style></legend>
                          1. 主站蜘蛛池模板: 日韩精品在线播放 | 亚洲激情在线观看 | 久久久久久综合 | 亚洲精品一区二区三区蜜桃久 | 国精产品一区二区三区 | 91在线免费观看 | 韩日一区 | 欧美 日韩 亚洲91麻豆精品 | 成人小视频在线观看 | 国产精品久久国产精品 | 在线视频 亚洲 | 久久国产美女视频 | 成人在线电影在线观看 | 国产农村一级片 | 99久久婷婷国产综合精品首页 | 人人玩人人添人人澡欧美 | 狠狠的干 | 欧美伊人影院 | 9久久婷婷国产综合精品性色 | 青青草av在线播放 | 国产91在线播放 | 91资源在线 | 亚洲三区视频 | 久久五月婷 | 国产在线观看一区二区 | 精品国产视频 | 欧美精品在线看 | 久草影视在线 | 成人精品久久 | 国产精品精品视频一区二区三区 | 亚洲一级黄色 | 最新中文字幕一区 | 69亚洲精品 | 国产精品亚洲精品日韩已方 | 欧美一级淫片免费视频黄 | 精品一区二区三区中文字幕 | 一区二区三区日韩 | 国产欧美久久精品 | 91xxx在线观看 | 成人av一区| 欧美日韩精品区 |