JSONP cross origin error 'No Access-Control-Allow-Origin header is present' JSONP cross origin error 'No Access-Control-Allow-Origin header is present' ajax ajax

JSONP cross origin error 'No Access-Control-Allow-Origin header is present'


The said resource supports jsonp, so there is no need for CORS... the problem is datatype: 'jsonp' it should be dataType: 'jsonp'

$(document).ready(function () {    $.ajax({        type: 'GET',        dataType: 'jsonp',        data: {},        url: "http://twitter.com/status/user_timeline/padraicb.json?count=10&callback=?",        error: function (jqXHR, textStatus, errorThrown) {            console.log(jqXHR)        },        success: function (msg) {            console.log(msg);        }    });});

Demo: Fiddle


The header is supposed to be set on Twitter's servers when they respond. If it is not available, then it means you cannot access this resource using AJAX from anywhere outside their own domain.
Hence, you can't use their API from javascript on the browser. You have have your own server set up which acts as an intermediate resource to communicate with Twitter API.

Edit: Also worth pointing out at this point that twitter is closing their unauthenticated API requests. You need to setup an app with twitter and use the API key to make requests.