I am using validation engine for form validation. When i completely load form its work fine.
Now i going to add some ajax functionality in my existing page. I add a category drop-down, in which some category have sub category, So when user select the category from drop down, if category have sub-cat then ajax function is called and i got the new drop down in my form, but when i submit my form the validation engine is not validate the sub category drop-down menu.
My Code is below :-
<div class="par control-group" >
<label for="main_category" class="control-label">Category</label>
<div class="controls">
<select data-placeholder="Choose a Main-Category" id="main_category" name="main_category" style="width:350px" class="chzn-select" tabindex="2">
<option value=""></option>
<option value="1">Cat-1</option>
<option value="2">Cat-2</option>
</select>
</div>
</div>
Ans this is Jquery code :-
$("#main_category").change(function(){
var cat_id = $(this).val();
$.ajax({
url: 'subcategory.php', //server script to process data
type: 'POST',
data:{'cat_id':cat_id},
beforeSend:function(){$('#loader_sub').show();},
success: function(response){
$('#subcategory_div').html(response);
// i try for re-declare validation engine
// $('form').validationEngine();
$("#sub_category").chosen();
$('#loader_sub').hide();
}
});
});
Ans i have a some code on server side which make a drop-down on the base of main category id.
So i try the re-declare the validation engine function, But there is problem with ajax form submission. The form submit two times in ajax.
Please help me for solve this problem.