Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #23751

Re: xhr call and changing page

From Denis McMahon <denismfmcmahon@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: xhr call and changing page
Date 2014-03-31 02:35 +0000
Organization A noiseless patient Spider
Message-ID <lhak9q$8uu$1@dont-email.me> (permalink)
References <YeKdnX0JJb6iW6XOnZ2dnUVZ_sidnZ2d@westnet.com.au>

Show all headers | View raw


On Mon, 31 Mar 2014 12:33:54 +1100, Andrew Poulos wrote:

> When I send some data using AJAX to the server (to save to a db) and
> then immediately navigate to a new page what seems to be happening is
> that no data gets to the db.
> 
> Does changing the page that made the AJAX call cause the call to get
> cancelled?
> 
> I'm trying to track an elearning course. When the user closes the window
> containing the course I have a loop in the parent page that checks for
> the course's window. If the window cannot be found it updates the server
> with the "logout" time and then navigates to the course selection page.

I suspect that any javascript on a web page executes in the context of 
the page that invokes it. Navigating away from that page probably 
terminates any executing code on the page. In the case of any outstanding 
ajax requests, I expect the browser would close the connections at the tcp 
level which were waiting for responses as the listener events would no 
longer be waiting at the javascript level.

If this drops the tcp connection, I have no idea what the server would 
receive, or how it would interpret it, but I can envisage that the server 
might see a closed connection as a request it should ignore (because it 
can't send a response).

I suspect therefore that this is going to be a server behaviour issue. 
What does the server do when the client drops the connection before the 
server has sent a response?

Do the server logs shed any light on what the server is seeing / doing? 
If not, can you increase the reporting level? If so, does that shed any 
light?

Perhaps the safest thing to do would wait until receiving a response from 
the server before changing page?

-- 
Denis McMahon, denismfmcmahon@gmail.com

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

xhr call and changing page Andrew Poulos <ap_prog@hotmail.com> - 2014-03-31 12:33 +1100
  Re: xhr call and changing page Denis McMahon <denismfmcmahon@gmail.com> - 2014-03-31 02:35 +0000
  Re: xhr call and changing page Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2014-03-31 19:23 +0200
  Re: xhr call and changing page Danny <dann90038@gmail.com> - 2014-03-31 11:48 -0700

csiph-web