Created
August 18, 2015 15:54
-
-
Save netmarkjp/e4383567c62859e01d34 to your computer and use it in GitHub Desktop.
ajax post form with jQuery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$("#enqueue_form").submit(function(event) { | |
event.preventDefault(); //cancel event | |
var form_data = new FormData($("#enqueue_form").get(0)); | |
$.ajax({ | |
url: "/bench", | |
type: "POST", | |
data : form_data, | |
dataType: "json", | |
processData: false, | |
contentType: false, | |
timeout:10000, | |
success: function(data) { | |
// do something | |
console.log(data); | |
}, | |
error: function(XMLHttpRequest, textStatus, errorThrown) { | |
// do something | |
console.log(XMLHttpRequest); | |
console.log(textStatus); | |
console.log(errorThrown); | |
} | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment