MrPolywhirl

JSONP - LiveStream

Aug 28th, 2014
481
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE html>
  2. <html>
  3.     <head>
  4.         <script type="text/javascript" src="https://code.jquery.com/jquery-1.11.1.min.js"></script>
  5.         <script type="text/javascript">
  6.             // JSONP or "JSON with padding" is a communication technique used in JavaScript programs
  7.             // running in web browsers to request data from a server in a different domain, something
  8.             // prohibited by typical web browsers because of the same-origin policy.
  9.             var url = "http://xproshowcasex.api.channel.livestream.com/2.0/livestatus.json"
  10.             $(document).ready(function() {
  11.                 var par1 = $("#par1");
  12.                 $.ajax({
  13.                     'url' : url,
  14.                     'dataType' : "jsonp",
  15.                     'success' : function(data) {
  16.                         if (data.isLive === true) {
  17.                             par1.html("live");
  18.                         } else {
  19.                             par1.html("offline");
  20.                         }
  21.                     }
  22.                 });
  23.             });
  24.         </script>
  25.     </head>
  26.     <body>
  27.         <p id="par1"></p>
  28.     </body>
  29. </html>
Add Comment
Please, Sign In to add comment