1

I've built a complex web app using angularjs, java and hibernate.

I'm using http request for saving the form data.

$http({
   method : 'POST',
   url : $scope.servlet_url,
   headers : {'Content-Type' : 'application/json'},
   data : $scope.deals
}).success(function(data) {

}).error(function(data) {

});

I'm using angular version 1.2.19.

When hitting the save button this request will be triggered with the data available in the form and it moves to the server where the data is saved in the database. Before saving into the database many validations are done and also some external data is fetched which are related to the form data. Hence, it takes some time to save. (approximately around 5 to 7 minutes based on the form data provided). After the data is saved i'm redirecting to another page based on the response provided.

But the response takes time in my case, and in the mean time the same request is triggered again without any clue. There's no place the request is called in the code, but the request is triggered. It's a bit confusing.

But the same code works fine if the save takes less than 5 minutes. If it exceeds 5 minutes, it goes into a infinite loop and the save happens as many times the request is triggered. The response for the first request hits the angular controller but the controller doesn't identify the response, means we can't handle the response in this case. If this happens the page gets struck and we manually need to refresh or move the page.

Is there any way to prevent the duplicate request in angularjs? If there is a way, could anyone please help me achieve it.

Thanks in advance.

2
  • Im thinking if it takes that long to process, you should reconsider what is happening at the backend or try to optimize it. Commented Jan 25, 2017 at 6:02
  • @DonaldJansen - I've already optimized the backend code. No other way to reduce the process in the server. Any other way to prevent it? Commented Jan 25, 2017 at 6:08

0

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.