Last active
February 8, 2018 22:44
-
-
Save nozzlegear/9e45a63675178b5d6261 to your computer and use it in GitHub Desktop.
Extending jQuery to send json in a post
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
jQuery.postJSON = function (url, data, success, dataType) { | |
if (dataType === void 0) { dataType = "json"; } | |
if (typeof (data) === "object") { data = JSON.stringify(data);} | |
var ajax = { | |
url: url, | |
type: "POST", | |
contentType: "application/json; charset=utf-8", | |
dataType: dataType, | |
data: data, | |
success: success | |
}; | |
return jQuery.ajax(ajax); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment