0
$(document).ready(function(){


        $("#submit").click(function()
                                    {

                    var name = $("#name").val();
                    var pass = $("#pass").val();
                    var image = $("#imagefile").val();
                    var comm = $("#comment").val();



                var data = 'name=' +name+ '&pass=' +pass+ '&imagefile=' +image+ '&comment='+comm;   

                    if(name=="" || pass=="")
                    {
                    $("#error").show();
                    return false;
                    }



        $.ajax({
           type: "POST",
           url: "submit.php",
           data: data, 
           success: function(data)
           {
               alert(data); // show response from the php script.
           }
         });

I


            });

});

i am trying to submit from with ajax but only imagename name not post on the next page.

Prabhuram
  • 1,268
  • 9
  • 15
ajay
  • 1,560
  • 2
  • 13
  • 16

2 Answers2

1

Make sure you have attribute enctype="multipart/form-data" included in your form tag.

pinaldesai
  • 1,835
  • 2
  • 13
  • 22
0

Please try this:

$.ajax({
   type: "POST",
   url: "submit.php",
   data: {name: name, pass : pass, imagefile: image, comment : comm}, 
   success: function(data)
   {
       // success code 
   }
});
Syed Ahmed
  • 1,635
  • 2
  • 16
  • 23