0

I have a website on which I load subpages into container div through jquery.load().

On one subpage after user fill in form and submits it. I use ajax to process this form. It is a long process (php search big database) and until I get success I cannot move to another supage because when i click other navigation button it stills on load() functions and waits until this ajax is finished. I dont want to freeze navigation because of this ajax did not finished. So load() cannot be executed until ajax finish? How to do that?

Vilis
  • 9
  • 5
  • You could put the form in an iframe and just submit it normally, without ajax. Since you're talking about navigating away from the page before you get a response I don't see the point in using ajax. What happens if there are errors in the form? – Reinstate Monica Cellio Sep 24 '14 at 15:22

1 Answers1

0

I would change my .load()'s into jQuery.get()'s. Then, I'd cancel my ajax call when the user clicks another nav button. Abort Ajax requests using jQuery. jQuery.get() returns a XHR (or equivelant) object just like $.ajax does.

Community
  • 1
  • 1
Clayton Leis
  • 1,288
  • 9
  • 20