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

<small id='98Ut8'></small><noframes id='98Ut8'>

      • <bdo id='98Ut8'></bdo><ul id='98Ut8'></ul>

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

        跨域 AJAX 請(qǐng)求不起作用

        Cross-domain AJAX request not working(跨域 AJAX 請(qǐng)求不起作用)

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

              <tbody id='qjWA2'></tbody>
              1. <legend id='qjWA2'><style id='qjWA2'><dir id='qjWA2'><q id='qjWA2'></q></dir></style></legend>
                • <bdo id='qjWA2'></bdo><ul id='qjWA2'></ul>

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

                  本文介紹了跨域 AJAX 請(qǐng)求不起作用的處理方法,對(duì)大家解決問(wèn)題具有一定的參考價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)吧!

                  問(wèn)題描述

                  我正在通過(guò) jQuery 的 $.ajax 函數(shù)在我一直使用的第三方 API 上調(diào)用 POST.但是,當(dāng)我撥打電話時(shí),我收到以下錯(cuò)誤:XMLHttpRequest 無(wú)法加載 http://the-url.com.該請(qǐng)求被重定向到http://the-url.com/anotherlocation",這對(duì)于需要預(yù)檢的跨域請(qǐng)求是不允許的.

                  I'm calling POST on a third-party API that I've been working with via jQuery's $.ajax function. However, when I make the call I get the following error: XMLHttpRequest cannot load http://the-url.com. The request was redirected to 'http://the-url.com/anotherlocation', which is disallowed for cross-origin requests that require preflight.

                  我從 這篇文章中看到 這可能是一個(gè) Webkit 錯(cuò)誤,所以我在 Firefox 中進(jìn)行了嘗試(我正在 Chrome 中開(kāi)發(fā)),我得到了相同的結(jié)果.我在 Chrome 和 Firefox 上嘗試過(guò),我得到了相同的結(jié)果.

                  I saw from this post that this might be a Webkit bug, so I tried it in Firefox (I'm developing in Chrome) and I got the same result.I've tried this on Chrome and Firefox and I get the same result.

                  根據(jù) 這篇文章,我還嘗試通過(guò)設(shè)置 crossDomain 來(lái)使用 jsonp$.ajax 函數(shù)的 屬性為 true 并將 dataType 設(shè)置為 jsonp.但是,這導(dǎo)致了 500 內(nèi)部服務(wù)器錯(cuò)誤.

                  Per this post, I also tried using jsonp both by setting the crossDomain property of the $.ajax function to true and setting the dataType to jsonp. But, this caused a 500 internal server error.

                  當(dāng)我使用 --disable-web-security 標(biāo)志啟動(dòng) Chrome 時(shí),我沒(méi)有任何問(wèn)題.但是,如果我正常啟動(dòng)瀏覽器,則會(huì)收到錯(cuò)誤消息.

                  When I start Chrome with the --disable-web-security flag, I don't have any problems. However, if I start the browser normally, then I get the error.

                  所以,我想這可能是一個(gè)由兩部分組成的問(wèn)題.我該怎么做才能發(fā)出這個(gè)跨域請(qǐng)求?如果 JSONP 是答案,那么我該如何確定第三方 API 是否設(shè)置正確以支持此功能?

                  So, I guess this might sort of be a 2-part question. What can I do to make this cross-domain request? If JSONP is the answer, then how do I go about figuring out if the third-party API is set up correctly to support this?

                  這是我在禁用瀏覽器安全性的情況下?lián)艽螂娫挄r(shí)的屏幕截圖:https://drive.google.com/file/d/0Bzo7loNBQcmjUjk5YWNWLXM2SVE/edit?usp=sharing

                  Here's the screenshot when I make the call with the browser security disabled: https://drive.google.com/file/d/0Bzo7loNBQcmjUjk5YWNWLXM2SVE/edit?usp=sharing

                  這是我在啟用瀏覽器安全性的情況下(正常情況下)撥打電話時(shí)的屏幕截圖:https://drive.google.com/file/d/0Bzo7loNBQcmjam5NQ3BKWUluRE0/edit?usp=sharing

                  Here's the screenchost when I make the call with the browser security enabled (like normal): https://drive.google.com/file/d/0Bzo7loNBQcmjam5NQ3BKWUluRE0/edit?usp=sharing

                  推薦答案

                  我想出的解決方案是使用 cURL(正如 @waki 所提到的),但稍微修改了一個(gè)支持 SOAP 的版本.然后,我沒(méi)有對(duì)第三方 API 進(jìn)行 AJAX 調(diào)用(配置不正確),而是調(diào)用我的本地 PHP 文件,該文件然后對(duì)第三方 API 進(jìn)行 SOAP 調(diào)用并將數(shù)據(jù)傳遞回我的 PHP 文件,我可以然后處理它.這讓我忘記了 CORS 以及與之相關(guān)的所有復(fù)雜性.這是代碼(取自this問(wèn)題,但沒(méi)有經(jīng)過(guò)身份驗(yàn)證).

                  The solution that I came up with was to use cURL (as @waki mentioned), but a slightly modified version that supports SOAP. Then, instead of making the AJAX call to the third party API (which is configured incorrectly) I make the call to my local PHP file which then makes a SOAP call to third party API and passes the data back to my PHP file where I can then process it. This allows me to forget about CORS and all of the complexities associated with it. Here's the code (taken and modified from this question, but without the authentication).

                  $post_data = "Some xml here";
                  $soapUrl = "http://yoursite.com/soap.asmx"; // asmx URL of WSDL
                  
                  
                  $headers = array(
                      "Content-type: text/xml;charset="utf-8"",
                      "Accept: text/xml",
                      "Cache-Control: no-cache",
                      "Pragma: no-cache",
                      "SOAPAction: http://yoursite.com/SOAPAction",
                      "Content-length: " . strlen($post_data),
                  ); //SOAPAction: your op URL
                  
                  $url = $soapUrl;
                  
                  // PHP cURL
                  $ch = curl_init();
                  curl_setopt($ch, CURLOPT_URL, $url);
                  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                  curl_setopt($ch, CURLOPT_POST, true);
                  curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data); // the SOAP request
                  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
                  
                  $response = curl_exec($ch);
                  
                  /* Check for an error when processing the request. */
                  if(curl_errno($ch) != 0) {
                     // TODO handle the error
                  }
                  
                  curl_close($ch);
                  
                  // TODO Parse and process the $response variable (returned as XML)
                  

                  這篇關(guān)于跨域 AJAX 請(qǐng)求不起作用的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

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

                  相關(guān)文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調(diào)用 abort (jQuery) 之后,瀏覽器也會(huì)等待 ajax 調(diào)用完成)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無(wú)法加載,請(qǐng)求的資源上不存在“Access-Control-Allow-Origin標(biāo)頭) - IT屋-程序員軟件開(kāi)發(fā)技術(shù)分
                  Is it possible for XHR HEAD requests to not follow redirects (301 302)(XHR HEAD 請(qǐng)求是否有可能不遵循重定向 (301 302))
                  NETWORK_ERROR: XMLHttpRequest Exception 101(NETWORK_ERROR:XMLHttpRequest 異常 101)
                  XMLHttpRequest 206 Partial Content(XMLHttpRequest 206 部分內(nèi)容)
                  XmlHttpRequest onprogress interval(XmlHttpRequest onprogress 間隔)

                    • <small id='maX15'></small><noframes id='maX15'>

                      <legend id='maX15'><style id='maX15'><dir id='maX15'><q id='maX15'></q></dir></style></legend>
                        <bdo id='maX15'></bdo><ul id='maX15'></ul>
                        <i id='maX15'><tr id='maX15'><dt id='maX15'><q id='maX15'><span id='maX15'><b id='maX15'><form id='maX15'><ins id='maX15'></ins><ul id='maX15'></ul><sub id='maX15'></sub></form><legend id='maX15'></legend><bdo id='maX15'><pre id='maX15'><center id='maX15'></center></pre></bdo></b><th id='maX15'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='maX15'><tfoot id='maX15'></tfoot><dl id='maX15'><fieldset id='maX15'></fieldset></dl></div>
                          <tbody id='maX15'></tbody>
                          <tfoot id='maX15'></tfoot>
                          1. 主站蜘蛛池模板: 欧美成人精品 | av影片在线| 成年人在线视频 | 成人免费在线小视频 | 国产激情在线观看 | 成年免费大片黄在线观看一级 | 中文字幕日韩一区 | 欧美在线| 人人做人人澡人人爽欧美 | 欧美日韩一区二区三区四区 | 国产在线精品一区二区 | 午夜在线| 亚洲天堂av在线 | 亚洲精品一区二区三区蜜桃久 | 精品亚洲一区二区三区 | 日本黄视频在线观看 | 日日操视频 | 午夜视频一区二区 | 伊人伊人| aaa综合国产| 一区二区中文 | 国产精品久久国产精品99 gif | 国产精品成人国产乱 | 超碰91在线| 日韩免费高清视频 | 日韩欧美一区二区三区免费观看 | 91资源在线 | 国产日韩欧美一区 | 97视频免费| 国产精品久久久久久久岛一牛影视 | 黑人巨大精品欧美一区二区免费 | 成人精品国产免费网站 | 欧美一区二区在线观看 | 91电影| 日本精品久久久一区二区三区 | 欧美日韩精品久久久免费观看 | 久久久久国产一区二区三区四区 | 亚洲黄色高清视频 | 一级毛片免费 | 成人在线免费观看 | 日韩久久精品视频 |