0

Hi everyone I have a problem when I submit a form the other variables are submitted and inserted to the database but the image are not..

THIS IS MY CODES..

I want to submit my form with validation and also submit image but not working..

    <script type="text/javascript">
    $(document).ready(function(){
  $("#form2").validate({
         debug: false,
   rules:{

    icode: {
      required: true,
      maxlength: 30,
    },

    iname: {

      required: true,
      minlength: 5,
    },

    brandname: {

      required: true,
      minlength: 5,
    },

    bb: {

      required: true,
    },




   },
   messages: {

    icode: {
    required: "Please Enter Your Location Code",
    maxlength: "Item Code not greater than 30",

    },

    iname: {
      required: "Please Enter Item name",
      minlength: "Item Name Must at least 5 character",

    },

    brandname: {
      required: "Please Enter brand name",
      minlength: "Brandname Must At least 5 character",

    },

    bb: {

      required: "Please upload Image",
    },

   },

   submitHandler: function(form) {

    $.post('item-exec.php', $("#form2").serialize(), function(data) {
     $('#result').html(alert('Station Information Added'))
     $('#result').html(window.open('item.php', '_self'))


    });
   }
  });
 });

    </script>
  • Ajax itself can't send any type of `` values. Use [Form Data API](https://developer.mozilla.org/en-US/docs/Web/API/FormData) – Rahil Wazir Feb 18 '14 at 16:47
  • possible duplicate of [How can I upload files asynchronously with jQuery?](http://stackoverflow.com/questions/166221/how-can-i-upload-files-asynchronously-with-jquery) – Travis J Feb 18 '14 at 16:49
  • To send files with ajax, you need to work a little bit harder. Please see my answer [here](http://stackoverflow.com/questions/21503802/submit-form-django-form-with-imagefield-via-jquery-ajax-post/21537704#21537704) for a detailed example – yuvi Feb 18 '14 at 16:50

0 Answers0