Advertisement
Guest User

Untitled

a guest
Jul 24th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. controler.common = {
  2. getCEP1: function(cep){
  3. return $.getJSON('http://getcep-1/'+cep);
  4. },
  5. getCEP2: function(cep){
  6. return $.getJSON('http://getcep-2'+ cep);
  7. }
  8. }
  9.  
  10. var ctrlCommon = controllers.common;
  11. ctrlCommon.getCEP1(cep)
  12. .always(function(data, xhr){
  13. if(data.erro || xhr === 'error'){
  14. ctrlCommon.getCEP2(cep)
  15. .always(function(data, xhr){
  16. if(data.cep)
  17. // sucesso
  18. else
  19. // erro
  20. })
  21. }
  22. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement