Advertisement
cafreak

My AJAX JQuery API call

Sep 9th, 2015
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. $.ajax(
  2. {
  3. type: 'GET',
  4. datatype: 'HTML',
  5. url: api,
  6. data:
  7.     {
  8.         "username": username
  9.     },
  10. success: function(data)
  11.     {
  12.         log("API successfully called! OH YE!") 
  13.         if(data.indexOf('Unknown User') == -1 ){
  14.             log("User Found WOOHOO!");
  15.             document.body.innerHTML = content + '' + data;
  16.             document.getElementById("gh-eb").style.display = "none";
  17.                        
  18.             log("Notification Shown - I am almost done!");
  19.                        
  20.             document.getElementById("baytmeAcceptButton").addEventListener("click", function(){buttonClick("accepted");});
  21.             document.getElementById("baytmeDenyButton").addEventListener("click", function(){buttonClick("denied");});
  22.         }else{
  23.             log(data+" AYYY CARAMBA!");
  24.         }
  25.     },
  26.                    
  27. error: function(data)
  28.     {
  29.         log("Request error\nStatus: " + data.status + "\nStatus Text: " + data.statusText);
  30.     }
  31. }
  32. );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement