Created
September 29, 2019 18:40
-
-
Save mcunha98/926021db2c12017c603ea2f31045de24 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| (function ($) { | |
| $.postJSON = function (url, data) { | |
| var o = { | |
| url: url, | |
| type: "POST", | |
| dataType: "json", | |
| contentType: 'application/json; charset=utf-8' | |
| }; | |
| if (data !== undefined) { | |
| o.data = JSON.stringify(data); | |
| } | |
| return $.ajax(o); | |
| }; | |
| } (jQuery)); | |
| //estrutura de exemplo: | |
| $.postJSON('/post/url', {param1: "hello", param2: "world"}) | |
| .complete(function () { | |
| // Optional - fires when the operation completes, regardless of status | |
| }) | |
| .success(function () { | |
| // Optional - fires when operation completes successfully | |
| }) | |
| .error(function () { | |
| // Optional - fires when operation completes with error | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment