Last active
October 13, 2015 00:57
-
-
Save thiagomarinho/4113902 to your computer and use it in GitHub Desktop.
Atalho pra requisições ajax com callback tudo bunitin
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 ajaxRequest(config, complete, success, error) { | |
| jQuery.ajax(config) | |
| .complete(function(jqXHR, textStatus) { | |
| if (jQuery.isFunction(complete)) { | |
| complete(); | |
| } | |
| switch (textStatus) { | |
| case "error" : | |
| case "timeout" : | |
| case "abort" : | |
| case "parseerror" : | |
| if (jQuery.isFunction(error)) { | |
| error(jqXHR.responseText); | |
| } | |
| break; | |
| case "success" : | |
| case "notmodified" : | |
| if (jQuery.isFunction(success)) { | |
| success(jqXHR.responseText); | |
| } | |
| break; | |
| } | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment