簡體   English   中英

ajax請求在IE上不起作用

[英]ajax request not working on IE

function VReload()
{
     $.ajax({
         type: "GET",
         url: "/foo/",
         success: function (data) {
        $("#myid").html(data);
        }
     });
 }
 $(document).ready(function() { 
setInterval('VReload()', 1000)
});

這段代碼在Mozilla和chrome上運行正常,但在IE上卻無法正常工作。 IE上未觸發Ajax調用。 可能是什么原因。

通過執行以下操作關閉緩存:

$.ajax({
         type: "GET",
         cache: false,
         url: "/foo/",
         success: function (data) {
        $("#myid").html(data);
        }
     });

設置緩存為假

$.ajaxSetup({   cache: false    });

要么

$.ajax({
         cache: false,
         //other options

     });

嘗試這個:

function VReload()
{
     var timestamp = new Date();
     $.ajax({
         type: "GET",
         url: "/foo/" + "&timestamp=" + timestamp.getTime(),
         success: function (data) {
        $("#myid").html(data);
        }
     });
 }
 $(document).ready(function() { 
setInterval('VReload()', 1000)
});

使用jQuery的$ .get()函數

$.get('/foo/', {}, function(data){
 // whatever
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM