views:

271

answers:

3

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()', 10000);

}   

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"&gt;&lt;/script&gt;
<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..!

A: 
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 :-)

prodigitalson
Either way is valid. That's not the problem.
Josh Stodola
Yeah i realized that after the fact... the random cache line and other things... edited to that effect.
prodigitalson
This is not working.. IT still doesn't show in IE
Karem
+2  A: 

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);
  });
}    
Josh Stodola
Thank you for link. I tried this, but unfourtanly like the other its not working..
Karem
It's not working? Awww, what a shame. If only my ESP-level debugger wasn't full of bugs itself...
Josh Stodola
Its so weird its working perfectly on FF but not in IE
Karem
You probably have Javascript disabled LOL
Josh Stodola
no? try yourself www.leinstein.dk !
Karem
It is likely a HTTP header issue with your handler (ok.php)
Josh Stodola
When i enter http://leinstein.dk/ok.php in IE it shows "Hello World!"?
Karem
Right now this is what ok.php looks like:<?phpob_start();header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the pastob_flush();?> Hello World!
Karem
No content-type?
Josh Stodola
Thank you Josh!!!!
Karem
But: This does not work if the ok.php contains PHP ?
Karem
A: 

Why dont wrap your function in an ready jquery fucntion, like that you wont need to wait the loading of all the page element, just the DOM.

$(document).ready(function() {

});
Amirouche Douda