title: Access the data form Coursera api using jquery jsonp
body: <p>Today I was trying to access the coursera api using jquery after reading the <a href="https://tech.coursera.org/app-platform/catalog/" rel="nofollow">Coursera catalog</a> documentation. I wrote a code and got an error <code>No 'Access-Control-Allow-Origin' header is present on the requested resource.</code> So did some google and found that Jsonp can be used to make the cross domain request. So I simply used a $.ajax function to make a request to this <a href="https://api.coursera.org/api/catalog.v1/courses?ids=2,3&amp;fields=language,shortDescription&amp;includes=sessions&amp;fields=status&amp;categories" rel="nofollow">url</a> or say this <a href="https://api.coursera.org/api/catalog.v1/courses/2" rel="nofollow">simple url</a> and some other such urls, but failed. </p>
  
  <p>Data on the url is  like <code>{"elements":[{"id":2,"shortName":"ml","name":"Machine Learning","links":{}}],"linked":{}}</code></p>
  
  <p>I wrote the following code.</p>
  
  <pre><code>$(document).ready(function() {
  $.ajax({
      url: "https://api.coursera.org/api/catalog.v1/courses/2",
      type: "GET",
      dataType: 'jsonp',
      jsonpCallback: 'localJsonpCallback',
      contentType: 'application/json',
      success: function(){
          alert("success");
      },
      error:function(jqxhr, textStatus, error){
          alert("textStatus : " + textStatus + "\n error" + error);
      }   
    }); 
  
    function localJsonpCallback(data) {
    alert("localJsonpCallback : " + data);
    }
    });
  </code></pre>
  
  <p>The above code fails and goes to the error handler and the error its printing is  , <code>textstatus: parseError</code> and <code>Error: localJsonpCallback was not called</code>. I am not getting whats wrong with the code. Moreover in the console I am getting the error <code>Uncaught SyntaxError: Unexpected token :</code>  and <code>2?callback=localJsonpCallback&amp;_=1418037208234:1</code> when using url <a href="https://api.coursera.org/api/catalog.v1/courses/2" rel="nofollow">https://api.coursera.org/api/catalog.v1/courses/2</a>.</p>
  
  <p>Is it necessary to use the jsonp call back function? Can't we handle the direct response in success handler.</p>