0

I want to detect when the document has just started to load, so that I can make an ajax call right away...which will determine whether I need to navigate to another page or not. I don't want to wait for the entire page to load before firing the ajax, and then, possibly navigating away from this page on the basis of the result of this ajax request.

2
  • 4
    instead of making an ajax call as soon as a page loads, why aren't you just checking these conditions on the server before the page loads in the first place? seems like quite a waste of bandwidth. Commented Mar 30, 2012 at 19:41
  • Its to deal with the back button.. the first time I will do the checking whether the user is logged in at the server side.. but when the user has navigated away from the page, and then comes back.. the only way I can tell whether the page is to be displayed is through an ajax call asking the server Commented Apr 2, 2012 at 5:45

2 Answers 2

4

just put code in the head of the document, no? or at the start of the body.

Sign up to request clarification or add additional context in comments.

2 Comments

Agreed, the best option, is to simply make the call right away... Though I question even making such a call in the first place on the client, and not just doing it on the server.
Its to deal with the back button.. the first time I will do the checking whether the user is logged in at the server side.. but when the user has navigated away from the page, and then comes back.. the only way I can tell whether the page is to be displayed is through an ajax call asking the server
1
<script type="text/javascript"> 
  function pageLoad() { 
    // Initialization code here, meant to run once. 
  } 
</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.