JQuery ajax ($.load) & IE7 issue

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

JQuery ajax ($.load) & IE7 issue

Post 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');
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

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

Post 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?
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

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

Post 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);
 };
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

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

Post 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());
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

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

Post 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?
User avatar
kaszu
Forum Regular
Posts: 749
Joined: Wed Jul 19, 2006 7:29 am

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

Post 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.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

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

Post 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)
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

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

Post 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?
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

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

Post by Burrito »

I find your last two posts quite amusing...
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

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

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

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

Post 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.
User avatar
jaoudestudios
DevNet Resident
Posts: 1483
Joined: Wed Jun 18, 2008 8:32 am
Location: Surrey

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

Post 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:
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

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

Post by Burrito »

nay...I'm not easily offended. But yes I am a windows lover...
User avatar
Eran
DevNet Master
Posts: 3549
Joined: Fri Jan 18, 2008 12:36 am
Location: Israel, ME

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

Post 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
User avatar
Burrito
Spockulator
Posts: 4715
Joined: Wed Feb 04, 2004 8:15 pm
Location: Eden, Utah

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

Post 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**
Post Reply