Avatar of Dinesh Bali
Dinesh Bali
 asked on

Load page once jQuery ajax call is executed.

HI,

I am working on .Net application using C#
I JQuery, I wanted that page should not render until my ajax function is not executed.
Please advise the solution
Code below:
$( window ).load(function() {
        
		$.ajax({
        url: '/der/surface/userHasSession',
        data: { currURL: window.location.pathname + window.location.search },
        type: 'GET',
        xhrFields: { withCredentials: true },
        accept: 'application/json',
        async: false
    }).done(function (userdata) {
       
			console.log('Done');


    })
        
        .fail(function (jqXHR, textStatus, error) {
            console.log('Session Check Fail: ');
        })
}
		
});

Open in new window

.NET ProgrammingC#JavaScriptjQueryAJAX

Avatar of undefined
Last Comment
Dinesh Bali

8/22/2022 - Mon
ASKER CERTIFIED SOLUTION
leakim971

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Dinesh Bali

ASKER
Many thanks for your reply.

When I moved my script in body then I am getting error at below line. What is the reason?

$.cookie('VerifySSOLogin', '1');
Error is:
jquery-2.1.4.min.js:2 Uncaught TypeError: $.cookie is not a function
leakim971

you need to move the jQuery and cookie plugins inside this script block too
Dinesh Bali

ASKER
Really great.
It works fine.

Since it is taking time to load as too much processing on server for business rules.
Anyway we can put loader at the time of processing.

If you want I can raise another question for the resolution.

Please advise.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
Dinesh Bali

ASKER