IE9下JQuery發送ajax請求失效

來源:互聯網
上載者:User

標籤:doctype   項目   false   xxx   div   min   cti   class   query   

                    最近在做項目的時候,測試PC端網頁,在IE9下會失效,不能正常的發送POST請求,經過仔細的排查,發現是IE9下JQuery發送ajax存在跨域問題。

                    目前有兩種解決方案:

                    解決方案一:

                    設定瀏覽器安全屬性,啟用【通過域訪問資料來源】選項,如所示:

                                                    

 

 

 

                   解決方案二: 

                   調用ajax方法時,設定crossDomain為true,如所示:

<!DOCTYPE html><html>    <head>        <title>jQuery CORS in IE7 - IE10</title>        <script src="http://code.jquery.com/jquery-xxxx.min.js"></script>        <script>            $(document).ready(function() {              $.ajax({                url: "http://xxxx.php",                dataType: "text",                    async: true,                    type: ‘GET‘,                    cache: false,                    crossDomain: true ,                success: function(txt) {                    //TODO                }              });            });        </script>        </head>    <body>        IE7到IE10使用jQuery跨域!!!    </body></html>

 

 

IE9下JQuery發送ajax請求失效

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.