-1

Could anyone tell me why this code doesn't work? I can't even get the alert(); in init() to work right...

window.onload = init;

var downloadedstuff;

function init() {
alert();
   $.get('example.php' + '?v=' + Math.random(), success: function (data) { 
    downloadedstuff = data;

});
 doTimer();
 }
var t;
var timer_is_on=0;

function timedCount()
 {
  $.get('example.php' + '?v=' + Math.random(), success: function (data) { 
    if(data != downloadedstuff)
    {
    alert('SOMETHING HAPPENED!!!!');
    location.reload(true);
    }
    else
    {
    alert(data);
    }
 });
 t=setTimeout("timedCount()",5000);
 }
function doTimer()
 {
 if (!timer_is_on)
   {
   timer_is_on=1;
   timedCount();
   }
 }

once again, really sorry for all the questions, i just don't know what's wrong.

2
  • you know, alert() will generate an error as alert needs a string as parameter. Commented Sep 10, 2011 at 0:10
  • not in IE9, at least, but i'll add a string just in case :P Commented Sep 10, 2011 at 0:12

1 Answer 1

4

This line (which occurs twice):

$.get('example.php' + '?v=' + Math.random(), success: function(data) {

should be:

$.get('example.php' + '?v=' + Math.random(), function(data) {

since the : is for javascript objects

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.