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

  • <legend id='vow2Z'><style id='vow2Z'><dir id='vow2Z'><q id='vow2Z'></q></dir></style></legend>
    • <bdo id='vow2Z'></bdo><ul id='vow2Z'></ul>
    <tfoot id='vow2Z'></tfoot>

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

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

        MooTools CORS 請求與原生 Javascript

        MooTools CORS request vs native Javascript(MooTools CORS 請求與原生 Javascript)
        <tfoot id='GUim7'></tfoot>
      2. <i id='GUim7'><tr id='GUim7'><dt id='GUim7'><q id='GUim7'><span id='GUim7'><b id='GUim7'><form id='GUim7'><ins id='GUim7'></ins><ul id='GUim7'></ul><sub id='GUim7'></sub></form><legend id='GUim7'></legend><bdo id='GUim7'><pre id='GUim7'><center id='GUim7'></center></pre></bdo></b><th id='GUim7'></th></span></q></dt></tr></i><div class="qwawimqqmiuu" id='GUim7'><tfoot id='GUim7'></tfoot><dl id='GUim7'><fieldset id='GUim7'></fieldset></dl></div>
            <tbody id='GUim7'></tbody>

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

              <bdo id='GUim7'></bdo><ul id='GUim7'></ul>
              <legend id='GUim7'><style id='GUim7'><dir id='GUim7'><q id='GUim7'></q></dir></style></legend>

                • 本文介紹了MooTools CORS 請求與原生 Javascript的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

                  問題描述

                  我有這個 MooTools 代碼:

                  I have this MooTools code:

                  new Request.JSON({
                    method: 'POST',
                    url: URL, /*URL TO ANOTHER DOMAIN*/
                    onSuccess: function(r){
                      callback(r);
                    }
                  }).post(data);
                  

                  并且此代碼不發送 POST 請求(僅限 OPTIONS)...看看下面的代碼(效果很好):

                  And this code doesn't send POST requests (OPTIONS only)... Look at the code below (it works great):

                  var http = null,
                    params = Object.toQueryString(data);
                  try {
                    http = new XMLHttpRequest();
                  } catch (e) {
                    try {
                      http = new ActiveXObject("Msxml2.XMLHTTP");
                    } catch (e) {
                      try {
                        http = new ActiveXObject("Microsoft.XMLHTTP");
                      } catch (e) {
                        http = null;
                        alert("Your browser does not support AJAX!");
                      }
                    }
                  }
                  var url = URL;
                  http.onreadystatechange = function () {
                    if (http.readyState == 4 && http.status == 200) {
                      var jsonData = JSON.parse(http.responseText); /*OR EVAL*/
                      callback(jsonData);
                    }
                  };
                  http.open("POST", url);
                  http.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
                  http.send(params);
                  

                  編輯:

                  試過:.setHeader('Content-Type','application/x-www-form-urlencoded');
                  還是什么都沒有……哪里有問題?

                  Tried: .setHeader('Content-Type','application/x-www-form-urlencoded');
                  Still nothing... Where can there be a problem?

                  謝謝!

                  推薦答案

                  這是因為 MooTools 將一些額外的東西與請求標頭捆綁在一起.

                  This is because MooTools bundles some extra stuff with the request headers.

                  例如.如果你的 htaccess 說:

                  eg. if your htaccess says:

                  Header set Access-Control-Allow-Origin: *
                  

                  您需要像這樣制作您的請求:

                  you need to craft your request like that:

                  var foo = new Request({
                      url: 'http://fragged.org/Epitome/example/data/',
                      method: 'get',
                      onComplete: function (data) {
                          // returns an object with name and surname  
                          new Element('div[html="{name} {surname}"]'.substitute(JSON.decode(data))).inject(document.body);
                      }
                  });
                  
                  // need to remove that or CORS will need to match it specifically
                  delete foo.headers['X-Requested-With'];
                  foo.send();    
                  

                  這就是為什么您只能在飛行前看到 OPTIONS.它不喜歡你:)

                  This is why you are only seeing the OPTIONS pre-flight. It does not like you :)

                  您可以將 .htaccess 更改為也匹配 X-Requested-With,這可能是一些額外的安全性".

                  You could change the .htaccess to also match X-Requested-With, which is probably some extra "security".

                  有關工作示例,請參閱 http://jsfiddle.net/7zUSu/1/ - 我前段時間我想對 Request https://github.com 進行更改時這樣做了/mootools/mootools-core/issues/2381 已修復.

                  See http://jsfiddle.net/7zUSu/1/ for a working example - I did that a while ago when I wanted to get this change to Request https://github.com/mootools/mootools-core/issues/2381 fixed.

                  這篇關于MooTools CORS 請求與原生 Javascript的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

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

                  相關文檔推薦

                  Browser waits for ajax call to complete even after abort has been called (jQuery)(即使在調用 abort (jQuery) 之后,瀏覽器也會等待 ajax 調用完成)
                  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屋-程序員軟件開發技術分
                  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 部分內容)

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

                    • <bdo id='OdBvh'></bdo><ul id='OdBvh'></ul>

                          <legend id='OdBvh'><style id='OdBvh'><dir id='OdBvh'><q id='OdBvh'></q></dir></style></legend>

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

                        1. <tfoot id='OdBvh'></tfoot>
                            <tbody id='OdBvh'></tbody>

                            主站蜘蛛池模板: 2018国产大陆天天弄 | 九一在线 | 亚洲精品日韩一区二区电影 | 成人九色 | 在线观看不卡av | 久久久久亚洲精品 | 中文在线日韩 | 欧美成人一区二区三区 | 亚洲视频中文字幕 | 日韩中文字幕 | 亚洲高清网 | 欧美成年黄网站色视频 | 亚洲免费在线播放 | 亚洲成人av在线播放 | 日本免费黄色 | 欧美一级特黄aaa大片在线观看 | 美国一级黄色片 | 91麻豆久久久| 久久久久国产精品午夜一区 | 国产精品1区2区 | 亚洲在线中文字幕 | av入口| 国产毛片av | 羞羞视频一区二区 | 日韩国产高清在线观看 | av网站在线播放 | 国产精品综合网 | 日韩成人性视频 | 日韩欧美久久精品 | 亚洲不卡视频 | 综合二区| 91网站在线看 | 欧美日韩国产精品一区 | 欧美日韩一区二区电影 | 国产乱肥老妇国产一区二 | 亚洲欧美精品久久 | 国产精品一区二区三区99 | 一区二区视频在线观看 | 国产一区影院 | 91最新入口 | 欧美日韩高清一区二区三区 |