javascript - Image Upload JQuery form and PHP stop jumping page -


I am working on an image upload page. The upload works, but whenever I click submit, it goes to the php page, I have returned the wrong and stopping defaults. Is there a way to stop this from visiting the php page?

My html code

  & lt; Form action = "imageupload.php" method = "post" id = "image_form" enctype = "multiparty / form-data" & gt; & Lt; Input id = "update_image" name = "file" type = "file" maxlength = "40" & gt; & Lt; Input id = "image_submit" type = "submit" name = "submit" value = "submit" & gt; & Lt; / Form & gt; & Lt; Div id = "output" & gt; & Lt; / Div & gt;  

My JS code

  var option = {target: "#output", // target element / server response can be updated with Submit first: submit first, // reset pre-callback form: Reset form after correct / successful submission;}; $ ("# Image_form"). Submit (function (e) {$ (this) .ajaxSubmit (options); // Ajax submitting this form // submitting standard browser and return back to prevent the page navigation e.preventDefault ();;});  

try this

  & lt; Form action = "javascript: your function name" method = "post" id = "image_form" enctype = "multipart / form-data" & gt;  Try to replace  

or preventDefault

  $ ( "# image_form"). Submit (function (event) {event.preventDefault (); $ (this) .jax submit (option); // aaax form return false;});  

Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -