Skip to content

Instantly share code, notes, and snippets.

@gotoark
Created April 4, 2019 07:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gotoark/e68612fe53eb7887257c327a683a2c11 to your computer and use it in GitHub Desktop.
Save gotoark/e68612fe53eb7887257c327a683a2c11 to your computer and use it in GitHub Desktop.
Simple Ajax Request Format
var formData = new FormData();
$.ajax({
url : "${url}",
type : "POST",
contentType : false,
/* enctype: "multipart/form-data", */
processData : false,
data : function() {
var inputs = $('#formObject').serializeArray();
console.log("-----------------Sending "
+ JSON.stringify(inputs));
$.each(inputs, function(i, input) {
formData.append(input.name, input.value);
console.log("----------------- " + input.name
+ " - " + input.value);
});
return formData;
}(),
error : function(_, textStatus, errorThrown) {
console.log("Error thrown ----------" + textStatus, errorThrown);
},
success : function(data, response, textStatus) {
console.log(data, response, textStatus);
} //end of success
}); //end of ajax call
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment