title: How to get web service data with javascript?
body: <p>I have token value in a URL like <code>http://example.com/api.php?action=token</code>
  I need to consume this URL data which is a random string, I'm trying with following code:</p>
  
  <pre><code>var jqxhr = $.get("http://example.com/api.php?action=token", function() {
      alert( "success" );
  })
  .done(function() {
      alert( "second success" );
  })
  .fail(function() {
      alert( "error" );
  })
  .always(function() {
      alert( "finished" );
  });
  
  // Perform other work here ...
  
  // Set another completion function for the request above
  jqxhr.always(function() {
      alert( "second finished" );
  }); 
  </code></pre>
  
  <p>Using <a href="http://api.jquery.com/jQuery.get/" rel="nofollow"><code>$.get()</code></a></p>
  
  <p>While trying to load, it's showing an error. I'm just stuck with it, how to get the data?</p>