Skip to content

Instantly share code, notes, and snippets.

@PavloConan
Created August 21, 2018 11:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PavloConan/837d9c25ba11df120fb68b171b078b7a to your computer and use it in GitHub Desktop.
Save PavloConan/837d9c25ba11df120fb68b171b078b7a to your computer and use it in GitHub Desktop.
function synchronize() {
 messages = []
 function_counter = 0
 $.ajax({
   dataType: 'json',
   type: 'POST',
   url: Routes.call_to_api1_path(),
   beforeSend: function() {
     function_counter ++
   },
   error: function(data) {
     messages.push(data.error)
   },
   complete: function() {
     function_counter --
     if (function_counter == 0) {
       redirect(messages)
     }
   }
 })
 $.ajax({
   dataType: 'json',
   type: 'POST',
   url: Routes.call_to_api1_path(),
   beforeSend: function() {
     function_counter ++
   },
   error: function(data) {
      messages.push(data.error)
   },
   complete: function() {
     function_counter --
     if (function_counter == 0) {
       redirect(messages)
     }
   }
 })
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment