How to submit two forms one after another using java script

i want to upload documents by php by two forms. If I try to submit two forms one after another then only one form get submitted.The first form has 1 document which is not submitted . But the second form has 9 document which is submitted successfully.
My java script with ajax code is:

$.ajax({ type:"POST", url:"userFunctions.php", data:{action:"save_pass_heavy", app_id:app_id, ref_id:ref_id, f_name:f_name, l_name:l_name, fr_name:fr_name, gender:gender, dateofbirth:dateofbirth, mr_status:mr_status, present_add:present_add, permanent_add:permanent_add, state:state, pincode:pincode, stdcode:stdcode, land_line:land_line, mobile:mobile, police:police, photo:photo, pass_type:pass_type, pass_cat:pass_cat, pass_period:pass_period, requestdate:requestdate, company_name:company_name, pass_period:pass_period, requestdate:requestdate, company_name:company_name, vehicle_type:vehicle_type, vehicle_name:vehicle_name, lc_no:lc_no, reg_no:reg_no, ownersname:ownersname, file1:file1, file2:file2, file3:file3, file4:file4, file5:file5, file6:file6, file7:file7, file8:file8, file9:file9 }, success:function (res) { $("#save_pass").html( res ); document.save_pass.submit(); document.save_pass3.submit(); }
I want to submit save_pass form and save_pass3 form one after another.
And my PHP code for the forms is:
[php]



Auth CHA Ltr / Registered Party*









Select fileChange


Remove



   <div class="row-fluid">
    	<div class="span3 offset2 ">
        RC Book<span class="red">*</span>
        </div>
        <div class="span6">
        	<div class="fileupload fileupload-new" data-provides="fileupload">
              <div class="input-append">
                <div class="uneditable-input span3" id="file">
                  <i class="icon-file fileupload-exists"></i> 
                  <span class="fileupload-preview"></span>
                </div>
                <span class="btn btn-file">
                  <span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
                  <input type="file" id="rcbook" name="rcbook">
                </span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
              </div>
              </div>
        </div>
   </div>
   
   <div class="row-fluid">
    	<div class="span3 offset2 ">
        Insurance<span class="red">*</span>
        </div>
        <div class="span6">
        	<div class="fileupload fileupload-new" data-provides="fileupload">
              <div class="input-append">
                <div class="uneditable-input span3" id="file">
                  <i class="icon-file fileupload-exists"></i> 
                  <span class="fileupload-preview"></span>
                </div>
                <span class="btn btn-file">
                  <span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
                  <input type="file" id="insurance" name="insurance">
                </span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
              </div>
              </div>
        </div>
   </div>
   
   <div class="row-fluid">
    	<div class="span3 offset2 ">

Safety Certificate*









Select fileChange


Remove



   <div class="row-fluid">
    	<div class="span3 offset2 ">
        Road Tax<span class="red">*</span>
        </div>
        <div class="span6">
        	<div class="fileupload fileupload-new" data-provides="fileupload">
              <div class="input-append">
                <div class="uneditable-input span3" id="file">
                  <i class="icon-file fileupload-exists"></i> 
                  <span class="fileupload-preview"></span>
                </div>
                <span class="btn btn-file">
                  <span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
                  <input type="file" id="road_tax" name="road_tax">
                </span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
              </div>
              </div>
        </div>
   </div>
   
   <div class="row-fluid">
    	<div class="span3 offset2 ">
      Custom Certificate<span class="red">*</span>
        </div>
        <div class="span6">
        	<div class="fileupload fileupload-new" data-provides="fileupload">
              <div class="input-append">
                <div class="uneditable-input span3" id="file">
                  <i class="icon-file fileupload-exists"></i> 
                  <span class="fileupload-preview"></span>
                </div>
                <span class="btn btn-file">
                  <span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
                  <input type="file" name="custom_certificate" id="custom_certificate"/>
                </span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
              </div>
              </div>
        </div>
   </div>
   
   <div class="row-fluid">
    	<div class="span3 offset2 ">
  Trailor Certificate<span class="red">*</span>
        </div>
        <div class="span6">
        	<div class="fileupload fileupload-new" data-provides="fileupload">
              <div class="input-append">
                <div class="uneditable-input span3" id="file">
                  <i class="icon-file fileupload-exists"></i> 
                  <span class="fileupload-preview"></span>
                </div>
                <span class="btn btn-file">
                  <span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
                  <input type="file" name="trailor_certificate" id="trailor_certificate"/>
                </span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
              </div>
              </div>
        </div>
   </div>
   
   <div class="row-fluid">
    	<div class="span3 offset2 ">
       Driver Medical Certificate<span class="red">*</span>
        </div>
        <div class="span6">
        	<div class="fileupload fileupload-new" data-provides="fileupload">
              <div class="input-append">
                <div class="uneditable-input span3" id="file">
                  <i class="icon-file fileupload-exists"></i> 
                  <span class="fileupload-preview"></span>
                </div>
                <span class="btn btn-file">
                  <span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
                  <input type="file" name="medical" id="medical"/>
                </span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
              </div>
              </div>
        </div>
   </div>
    
   <div class="row-fluid">
    	<div class="span3 offset2 ">
       Fitness Certificate<span class="red">*</span>
        </div>
        <div class="span6">
        	<div class="fileupload fileupload-new" data-provides="fileupload">
              <div class="input-append">
                <div class="uneditable-input span3" id="file">
                  <i class="icon-file fileupload-exists"></i> 
                  <span class="fileupload-preview"></span>
                </div>
                <span class="btn btn-file">
                  <span class="fileupload-new">Select file</span><span class="fileupload-exists">Change</span>
                  <input type="file" name="fitness" id="fitness"/>
                </span>
                <a href="#" class="btn fileupload-exists" data-dismiss="fileupload">Remove</a>
              </div>
              </div>
        </div>
   </div>
   </form>[/php]

This is for the first form
and
[php]



Photo (.jpg only)*









Select fileChange


Remove

        </div>
  </div>
  
  </form>[/php]

This is for second form.
Thanks in advance.

MMmmm, the old ‘race condition’…

I had a very similar problem a while back, see stackoverflow for how i solved it.

Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service