Page 1 of 2

JQuery ajax ($.load) & IE7 issue

Posted: Sat Jan 17, 2009 7:26 pm
by jaoudestudios
For some reason none of my jquery ajax is firing in IE7, works fine in FF3, Chrome, Opera.

Any ideas?

The line of code is...

Code: Select all

$('div#dialog').load('php/load.php');

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 4:20 am
by kaszu
Tried with jQuery 1.2.6 and 1.3, works for me.
Is IE showing any errors? Is there any other code where it could fail?

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 4:25 am
by jaoudestudios
Thanks for trying (and with both versions). I tried with both and no luck. I do not get any errors, but I think I have just found my problem. It is actually not with the load function but with the timer that calls it.

I downloaded the timer from the jquery plugin repo/collection - its that that does not work.


Here is the code for the time, it is not many lines, but I not that great with JS, do you spot anything obvious that would not work in IE....

Code: Select all

/*
 *
 *  jQuery Timer plugin v0.1
 *      Matt Schmidt [http://www.mattptr.net]
 *
 *  Licensed under the BSD License:
 *      http://mattptr.net/license/license.txt
 *
 */
 
 jQuery.timer = function (interval, callback)
 {
 /**
  *
  * timer() provides a cleaner way to handle intervals  
  *
  * @usage
  * $.timer(interval, callback);
  *
  *
  * @example
  * $.timer(1000, function (timer) {
  *     alert("hello");
  *     timer.stop();
  * });
  * @desc Show an alert box after 1 second and stop
  * 
  * @example
  * var second = false;
  * $.timer(1000, function (timer) {
  *     if (!second) {
  *         alert('First time!');
  *         second = true;
  *         timer.reset(3000);
  *     }
  *     else {
  *         alert('Second time');
  *         timer.stop();
  *     }
  * });
  * @desc Show an alert box after 1 second and show another after 3 seconds
  *
  * 
  */
 
    var interval = interval || 100;
 
    if (!callback)
        return false;
    
    _timer = function (interval, callback) {
        this.stop = function () {
            clearInterval(self.id);
        };
        
        this.internalCallback = function () {
            callback(self);
        };
        
        this.reset = function (val) {
            if (self.id)
                clearInterval(self.id);
            
            var val = val || 100;
            this.id = setInterval(this.internalCallback, val);
        };
        
        this.interval = interval;
        this.id = setInterval(this.internalCallback, this.interval);
        
        var self = this;
    };
    
    return new _timer(interval, callback);
 };

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 5:16 am
by kaszu
Tried and it works without problems, don't see anything what wouldn't work in IE.
Only problem what I found was cache. Request is cached and returned even after page refresh. If your php was returning an empty response before then now it would be empty too. Could it be empty instead of not executing?
Try:

Code: Select all

$('div#dialog').load('php/load.php?random=' + (new Date()).getTime());

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 5:25 am
by jaoudestudios
My php is definitely returning values - it works in all other browsers.
$('div#dialog').load('php/load.php?random=' + (new Date()).getTime());
I think that worked, but I dont understand why?

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 5:36 am
by kaszu
When ajax request for 'php/load.php' was executed, then result was cached by IE and returned on each next request for 'php/load.php'.
I think it was empty when 'php/load.php' was loaded first time.

Code: Select all

'php/load.php?random=' + (new Date()).getTime()
creates unique URL for each request (at least it makes browser think it's different that previous ones), for which cache doesn't exist, so it's really executed instead of being loaded from cache.

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 5:48 am
by jaoudestudios
Ah I see. Thank you. :)

So basically it confirms another reason why IE is poo? The issue did not happen in any other browser. - Not that I want to start a browser war, there are many other threads on this, but you must agree that IE has too many flaws? (which ever version)

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:15 am
by jaoudestudios
Also with the script running every half second, FF3 within about 30mins start to use over 200MB of ram and this keeps increasing, but all other browsers (including IE) do not. Is there a way to release/free the memory?

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:20 am
by Burrito
I find your last two posts quite amusing...

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:28 am
by jaoudestudios
Burrito wrote:I find your last two posts quite amusing...
Why? Because of my passion for opensource & I am totally against Microsoft & IE? :P

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:29 am
by Burrito
jaoudestudios wrote:Why? Because of my passion for opensource & I am totally against Microsoft & IE? :P
I'm pretty sure I don't need to explain why.

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:35 am
by jaoudestudios
Burrito wrote:I'm pretty sure I don't need to explain why.
I hope I did not offend you...You're not a Windows lover are you? :P

It was only a little dig 8) - and totally true :lol:

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:39 am
by Burrito
nay...I'm not easily offended. But yes I am a windows lover...

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:40 am
by Eran
Burrito was probably referring to you ranting on IE in one post and then ranting on FF in the very next. Moral of the matter - no browser is perfect

Re: JQuery ajax ($.load) & IE7 issue

Posted: Sun Jan 18, 2009 11:41 am
by Burrito
pytrin wrote:Burrito was probably referring to you ranting on IE in one post and then ranting on FF in the very next. Moral of the matter - no browser is perfect
**bingo**