开发者

Another IE jQuery AJAX/post problem

OK so i have this website, http://www.leinstein.dk.

You will see "Hello World!" This is from ok.php, ive made a script that refreshes ok.php after 10 seconds. Anyways, This does not show in IE. I dont know why, and i hope you can help me out.

Here's My script:

function ajax_update()
{
      cache: false
 /* var wrapperId  = '#wtf'; */
 var postFile = 'ok.php';
    $.post("ok.php", function(data){
 cache: false
          $("#wtf").html(data);
      });  
 setTimeout('ajax_update()', 1000开发者_StackOverflow中文版0);

}   

And here's index.php:

<?
header("cache-control: no-cache");
?>
<html>
<head>
<link href="style.css" type="text/css" rel="stylesheet" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="ajax_framework.js" language="javascript" charset="UTF-8"></script>
</head>
<!-- AJAX UPDATE COMMENTS BEGIN -->
<body onload="ajax_update();">
<!-- AJAX UPDATE END -->
<br>

<div id="wtf"></div>
</body>
</html>

Thank you in forward..!


You can't just put cache: false throughout your code in random spots. Please learn basic Javascript syntax before starting to write code. You'll probably learn much more by following a basic tutorial than posting a bunch of localized questions here on StackOverflow.

I will, however, show you what your function should look like this time. But I strongly recommend reading the tutorial that I have provided a link to.

function ajax_update()  { 
  $.post("ok.php", function(data){ 
    $("#wtf").html(data); 
    setTimeout(ajax_update, 10000);
  });
}    


function ajax_update()
{
      var postFile = 'ok.php';

      $.post("ok.php", function(data){
          $("#wtf").html(data);
      });  

    setTimeout(ajax_update, 10000);
}

Youre also going to run into a situation where youre trying to modify the DOM before its ready because youre invoking this function at body.onLoad but the entire page needs to beready in order to use $('#wtf'). you need to rethink this... and probably brush up on js syntax :-)


Why not wrap your function in a ready jQuery function, like that you wont need to wait the loading of all the page element, just the DOM.

$(document).ready(function() {

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜