jQuery Form Plugin submit to multiple sites.
Hello,
I'm currently trying to use the jQuery Form Plugin to submit my form containing a file to upload and some other data to my 5 other servers.
I'm using a php file with the following code to submit the form. It is working on every server and the file is getting uploaded correctly by the jsp usually. There are times when it will fail and maybe only the 1st and 5th will have the file. I'm thinking that maybe this is a syncing issue? Something to do with them all being called right away? Would there be any way to call them one after another as in letting the first one finish before submitting to the second?
How can I make sure the form gets submitted to each one every time?
- <script type="text/javascript">
// wait for the DOM to be loaded
$(document).ready(function() {
// bind to the form's submit event
$('#pageForm').submit(function() {
// inside event callbacks 'this' is the DOM element so we first
// wrap it in a jQuery object and then invoke ajaxSubmit
var optionsvz1 = { target: '#vz1', url: "http://server1.com/foo1/extractor.jsp"}
var optionsvz2 = { target: '#vz2', url: "http://server1.com/foo2/extractor.jsp"}
var optionsvz4 = { target: '#vz4', url: "http://server1.com/foo4/extractor.jsp"}
var optionsvz6 = { target: '#vz6', url: "http://server1.com/foo6/extractor.jsp"}
var optionsvz7 = { target: '#vz7', url: "http://server1.com/foo7/extractor.jsp"}
if (document.pageForm.vz1check.checked){ $(this).ajaxSubmit(optionsvz1); }
if (document.pageForm.vz2check.checked){ $(this).ajaxSubmit(optionsvz2); }
if (document.pageForm.vz4check.checked){ $(this).ajaxSubmit(optionsvz4); }
if (document.pageForm.vz6check.checked){ $(this).ajaxSubmit(optionsvz6); }
if (document.pageForm.vz7check.checked){ $(this).ajaxSubmit(optionsvz7); }
// !!! Important !!!
// always return false to prevent standard browser submit and page navigation
return false;
});
});
</script>