0

Good day,

I have a page with several javascript pages that get loaded. How can I check that all the JS files have been loaded? I tried the below with just alert boxes.

    $(onPageLoad);

function onPageLoad() {

    $.ajax({
        dataType: "json",
        type: "POST",
        contentType: "application/json; charset=utf-8",
    })
     .done(function (data) {

alert("Passed");         
     })
    .fail(function () {

        alert("Failed");
    });
}

The alert does fire and shows Failed. What am I missing in my ajax call?

closed as off-topic by user2536, Robert Lindgren Dec 11 '13 at 9:31

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Programming questions not specific to SharePoint are off-topic here, but can be asked on Stack Overflow." – Community, Robert Lindgren
If this question can be reworded to fit the rules in the help center, please edit the question.

4

why are you using ajax post event? that is like a click event to post to the server yet your checking for somthing on the client side!

how about you wait on the dom to finish, you could have a loading event like a gif that loops that shows.... once the dom is complete you could fade out that image!

$(window).load(function() {
    $(".loadingImage").fadeOut("slow");
})

the above is going to wait for the dom to be ready before it fades out, that inclueds loading all js files!

.loadingImage is the class name of a div that will hold the rotating gif

<div class="loadingImage"><></></div>

css for the div that holds the rotating loading image.

.loadingImage
{
    position: fixed;
    left: 0px;
    top: 0px;
    width: 100%;
    height: 100%;
    z-index: 1500;
    background: url('/_layouts/images/loader.gif');
}

here were making it fixed and at the full size of the screen, were also making the position starting from the top/left and making the div image at the front of everything.

  • Ah ok, I get what you mean. The above method works perfectly! Keep well – Chester238 Dec 11 '13 at 9:24
  • no problem happy to help! – Ali Jafer Dec 11 '13 at 9:36

Not the answer you're looking for? Browse other questions tagged or ask your own question.