使用jquery验证和多个文件上传在ajax中提交表单

时间:2018-12-10 10:05:21

标签: php jquery ajax

在提交表格时,如果数据已经存在于表中,则不应该提交,而是提交,即使在提交了旧数据后(即使使用旧数据提交(我使用print_r检查)也可以更改数据),它在控制台中显示了旧数据,但是我更改了表格中的数据!没有ajax提交工作正常

验证也不会影响

 $('#Employment_details').submit(function(e){

  var formData = new FormData(this);
  e.preventDefault();



   $("#Employment_details").validate({
      rules:{
        job_type:{
          required:true,
        },
        salary:{
          required:true,
        },
        working_years:{
          required:true,
          maxlength:"2"
        },
        company_name:{
          required:true,
        },
        company_address:{
          required:true,
        },
        pancard:{
          required:true,
        },
        aadhar_no:{
          required:true,
        },
        file_upload:{
          required:true,
        },
      },
      messages:{
        job_type:{
          required:"Please select an option!."
        },
        salary:{
          required:"This field is required!."
        },
        working_years:{
          required:"This field is required!."
        },
        company_name:{
          required:"This field is required!."
        },
        company_address:{
          required:"This field is required!."
        },
        pancard:{
          required:"This field is required!."
        },
        aadhar_no:{
          required:"This field is required!."
        },
        file_upload:{
          required:"This field is required!."
        },
      },
    submitHandler:function(form){
      $.ajax({
           type:'POST',
           url:"<?php echo base_url('home/job_details');?>",
           data:formData,
           cache: false,
           contentType:  false,
           processData: false,
           success:function(response){
           console.log(response); 
            if(response == "Registered successfully")
            {

                alert("You are ready to apply loan!");

            }else{
               alert("Already Registered With this Pancard and Aadhar!.");
                 }
           }
       });
     }
   });

  });

0 个答案:

没有答案