Created
April 4, 2019 07:26
-
-
Save gotoark/e68612fe53eb7887257c327a683a2c11 to your computer and use it in GitHub Desktop.
Simple Ajax Request Format
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
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