久久久久久久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 請求不起作用

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

      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 請求不起作用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我正在通過 jQuery 的 $.ajax 函數在我一直使用的第三方 API 上調用 POST.但是,當我撥打電話時,我收到以下錯誤:XMLHttpRequest 無法加載 http://the-url.com.該請求被重定向到http://the-url.com/anotherlocation",這對于需要預檢的跨域請求是不允許的.

                  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.

                  我從 這篇文章中看到 這可能是一個 Webkit 錯誤,所以我在 Firefox 中進行了嘗試(我正在 Chrome 中開發),我得到了相同的結果.我在 Chrome 和 Firefox 上嘗試過,我得到了相同的結果.

                  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.

                  根據 這篇文章,我還嘗試通過設置 crossDomain 來使用 jsonp$.ajax 函數的 屬性為 true 并將 dataType 設置為 jsonp.但是,這導致了 500 內部服務器錯誤.

                  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.

                  當我使用 --disable-web-security 標志啟動 Chrome 時,我沒有任何問題.但是,如果我正常啟動瀏覽器,則會收到錯誤消息.

                  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.

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

                  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?

                  這是我在禁用瀏覽器安全性的情況下撥打電話時的屏幕截圖: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

                  這是我在啟用瀏覽器安全性的情況下(正常情況下)撥打電話時的屏幕截圖: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 所提到的),但稍微修改了一個支持 SOAP 的版本.然后,我沒有對第三方 API 進行 AJAX 調用(配置不正確),而是調用我的本地 PHP 文件,該文件然后對第三方 API 進行 SOAP 調用并將數據傳遞回我的 PHP 文件,我可以然后處理它.這讓我忘記了 CORS 以及與之相關的所有復雜性.這是代碼(取自this問題,但沒有經過身份驗證).

                  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)
                  

                  這篇關于跨域 AJAX 請求不起作用的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  XMLHttpRequest cannot load, No #39;Access-Control-Allow-Origin#39; header is present on the requested resource(XMLHttpRequest 無法加載,請求的資源上不存在“Access-Control-Allow-Origin標頭) - IT屋-程序員軟件開發技術分
                  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 部分內容)
                  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 | 国产精品精品久久久 | 国产综合区| 福利视频一区二区 | 国产ts人妖系列高潮 | 久久99精品久久久久久秒播九色 | 中文字幕第90页 | 欧美乱大交xxxxx另类电影 | 中文精品视频 | 一区二区三区高清不卡 | 国产中文一区二区三区 | 九九热最新地址 | 久久久久中文字幕 | 欧美日韩在线一区二区 | 一级黄色大片 | 最新中文字幕在线 | 精品成人佐山爱一区二区 | 成人av电影免费在线观看 | 国产性网 | 久久r精品 | 无码一区二区三区视频 | 久久国产精彩视频 | 国产亚洲久 | 国内精品久久久久 | 成人在线观看网站 | av黄色在线播放 | 草久网| 日本在线观看视频 | 国产精品久久久久久久久久久新郎 | 亚洲精品欧美 | 国产精品成人一区二区三区 | 国产精品美女一区二区 | 中文字幕一区二区视频 | 亚洲一区二区中文字幕在线观看 | 一级做a爰片性色毛片 | 日韩中文字幕 | 99亚洲|