Created
September 23, 2014 08:48
-
-
Save sohelamin/75cdb08ebceda99f5c87 to your computer and use it in GitHub Desktop.
Multiple Form Submitt Simultaneously Via Jquery-Ajax
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
function submitAllForm() { | |
$('form').each(function (index, value) { | |
//iteration | |
var $form = $(this); | |
var form_id=$form.attr("id"); | |
if(form_id!='client_details'&&form_id!='hvac'&&form_id!='bms'&&form_id!='refrigeration_equipment'&&form_id!='lighting'){ | |
$.post($form.attr("action"), $form.serialize(), function (response) { | |
$form.attr("action", "<?php echo base_url('admin/clientDetailsUpdate');?>"); | |
<?php if($this->uri->segment(2)=='clientDetailsAdd'){?> | |
var id=parseInt(response); | |
if ($("#"+form_id+" #"+form_id+"_id").length < 1) { | |
$("<input name='"+form_id+"_id' id='"+form_id+"_id' type='hidden' value='"+id+"'/>").appendTo($form); | |
} | |
<?php } ?> | |
}).always(function() {}); | |
} | |
if(form_id=='hvac') { | |
$('form#hvac').submit(); | |
} | |
if(form_id=='bms') { | |
$('form#bms').submit(); | |
} | |
if(form_id=='refrigeration_equipment') { | |
$('form#refrigeration_equipment').submit(); | |
} | |
if(form_id=='lighting') { | |
$('form#lighting').submit(); | |
} | |
}).promise().always(function(){ }); | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment