dtmwnqng38644 2014-10-20 09:56
浏览 22

验证验证引擎中的ajax HTML响应


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.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 Vue3 大型图片数据拖动排序
    • ¥15 划分vlan后不通了
    • ¥15 GDI处理通道视频时总是带有白色锯齿
    • ¥20 用雷电模拟器安装百达屋apk一直闪退
    • ¥15 算能科技20240506咨询(拒绝大模型回答)
    • ¥15 自适应 AR 模型 参数估计Matlab程序
    • ¥100 角动量包络面如何用MATLAB绘制
    • ¥15 merge函数占用内存过大
    • ¥15 使用EMD去噪处理RML2016数据集时候的原理
    • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大