I am facing thread issue in my application follow are the summary of the issue
: root cause of the code
document.strikeoffForm.submit();
window.open('<%= baseURL %>/jsps/makeStrikeOffs/Print.jsp', "printStrikeoff");
its happening because of Asynchronous call. the issue is I am doing like this,
submitting form
opening new window to show the submitted value.
But some time before submiting a form the 2 action happened beacuse of Asynchronous call.
All I want is how can I order things as once first call is finished than only second call of window open should happen. Because of this issue the window doesn't get proper values.
I think the solution in Ajax but I am not aware how to do.
This is very easy with a little JQuery and a little bit of AJAX. Try the code below:
$.ajax({
type: 'POST',
url: 'pageToSubmitTo.jsp',
data: {
$("#idOfYourForm").serialize()
},
beforeSend:function(){
// this is where we append a loading image
},
success:function(data){
// successful request;
window.open('jsps/makeStrikeOffs/Print.jsp', "printStrikeoff");
},
error:function(){
// failed request; give feedback to user
}
});
For this to work you have to include the JQuery library to your code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With