Advertisement
Guest User

Untitled

a guest
Jan 29th, 2016
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. function _AJAXRequestStates(request, whenOk, whenFailed, atEnd) {
  2.  
  3. if (request.readyState === 4) {
  4. if (request.status === 200) {
  5. if (whenOk !== undefined && whenOk !== null) {
  6. if (!checkIsAFunction(whenOk)) {
  7. throw new Error("The parameter whenOk must be a function")
  8. }
  9.  
  10. whenOk(request.responseText);
  11. }
  12. }
  13.  
  14. else {
  15. if (whenFailed !== undefined && whenFailed !== null) {
  16. if (!checkIsAFunction(whenFailed)) {
  17. throw new Error("The parameter whenFailed must be a function")
  18. }
  19.  
  20. whenFailed(request.responseText);
  21. }
  22. }
  23.  
  24. if (atEnd !== undefined && atEnd !== null) atEnd(request.responseText);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement