Shamoon
Shamoon

Reputation: 43617

How come jQuery doesn't always load?

In my code, I have:

$(document).ready(function() {
    $.ajaxSetup ({
        // Disable caching of AJAX responses */
        cache: false
    });

    //pop_i = setInterval( "load_result()", 1000 );
    load_result();
    load_f();
});

but it doesn't always load. I know this because load_f() has an alert which doesn't get triggered sometimes.

Upvotes: 1

Views: 339

Answers (3)

shuckster
shuckster

Reputation: 5427

If you are sure your JavaScript looks right and you're not getting any errors in Firebug, chances are it's the JSON being sent back from the server that's tripping things up.

Where load_f fails to run copy-paste the result of your GET/POST requests from Firebug into your text-editor and pour through them with a fine-tooth comb to make sure the JSON is well-formed.

Upvotes: 1

HOCA
HOCA

Reputation: 1083

Don't know if this applies to your situation.

I've just come across an issue whereby $(document).ready() event wasn't being fired. As it turns out, the jQuery $(document).ready() event is not fired in async postbacks when used w/ ASP.net UpdatePanels. One solution is to refactor the $(document).ready() logic into an explicit function () so that it can also be registered w/ the ASP.net Sys.WebForms.PageRequestManager endRequest event (fired on every async postback). Details can be found on the question I posted earlier today...

Upvotes: 2

rfunduk
rfunduk

Reputation: 30452

What happens in load_result and load_f? Since the ready function attaches a listener, if an error occurs you will sometimes not see it.

Upvotes: 1

Related Questions