Link to home
Start Free TrialLog in
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

ASKER CERTIFIED SOLUTION
Avatar of leakim971
leakim971
Flag of Guadeloupe image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Dinesh Bali
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
you need to move the jQuery and cookie plugins inside this script block too
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.