0

When I issue an $.ajax query with a timeout: parameter, and my timeout is met such that error: is invoked, what does that mean?

More specifically: does that mean the server received the request, but is still processing it? That may mean some effect may occur, so I may have to cancel it on the server, or somehow invalidate data that was already partially written to a database.

Or does that mean I was never able to reach the server at all? This is nice to know since then I don't have to deal with partial data on a server "save"

Or does that mean the request made it part of the way, and now we lost track of it? In this case, I'd have to actually ask the server, "Oh hey, about that request I sent awhile ago... did you get that one? yeah? okay ignore that last save"

OS Commands like tracert make it clear there may be many servers for a TCP command to go through, so if one becomes unresponsive, it's hard to tell if it got it or not. But some protocols require an echo-back to be considered receivable (so I'm not sure if HTTP or Apache is involved in this)

Jonathan
  • 6,741
  • 7
  • 52
  • 69
  • It should not be possible to write partial data to the database in the first place. If you need to e.g. insert over multiple table start a transaction – PeeHaa Oct 06 '15 at 10:01
  • Yes, unless you write data over multiple AJAX requests (which is of course, unadvisable). This is likely to happen for batch file uploads or something where you may be creating thumbnails server side or having to post the file data seperately because it is so large – Jonathan Oct 06 '15 at 10:02
  • Nobody should ever do that / does that because it makes no sense to allow data to be in an inconsistent state like that. "because it is so large" Wut? How large? – PeeHaa Oct 06 '15 at 10:03
  • Depends on how big the data is. If your data is 1.5GB, then are you really saying you should do that in one request? – Jonathan Oct 06 '15 at 10:03
  • Yes that is what I am saying – PeeHaa Oct 06 '15 at 10:03
  • What if you want it to be resumable? If it fails at 1.4GB, and it's one request, you can't resume – Jonathan Oct 06 '15 at 10:04
  • 1
    Yes you can http://stackoverflow.com/questions/19907628/transfer-encoding-chunked – PeeHaa Oct 06 '15 at 10:04
  • BTW it's really hard to guess what your actual quetsion is, because your comments say something different than your question – PeeHaa Oct 06 '15 at 10:07
  • My comments are merely hypothetical, the question is more general. Theres a lot of server-side implications beside database-writes which are interesting, such as session storage, client side assumptions, local storage, cookies, tokens, UI state, and on and on. But I did learn about chunked HTTP transfer which was interesting. The specific reality I'm facing is lots of data uploaded over mobile phones using specially installed amplifying antennaes in remote areas causing lots of timeouts – Jonathan Oct 06 '15 at 10:12

1 Answers1

1

It is how long the client will wait to hear from the server before giving up.

The server may or may not have done its part. The only way for the client to know about that is for the client to be notified. Since you don't want to to leave a process or a human waiting forever, by using a timeout you specify the time to wait for success before giving up.

Michael Durrant
  • 93,410
  • 97
  • 333
  • 497
  • Okay that's what I figured. Due to physical limitations (such as line of sight radio) this makes the most sense. – Jonathan Oct 06 '15 at 10:10