I have been trying to use jquery to fiddle with cross domain requests but although the request succeeds the browser complains about not being able to parse the results. I understand that JsonP has a callback parameter attached to it but all the questions on SO never clarify how the callbacks are actually called. Could someone clarify how the callbacks from JsonP are executed and help me with this.
<body>
<ul id="tweets">Test</ul>
</body>
Javascript for this
window.myCallback = function(data) {
console.log(data);
$("#tweets").append("<div>Hello</div>");
};
$(document).ready(function(){
$.ajax({
url: 'http://www.netflix.com',
type: 'GET',
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'myCallback',
contentType: 'text/html',
success: function (data) {
alert(data);
}
});
});
I also have a JsFiddle here http://jsfiddle.net/3yVC7/
So in this example I just want to modify the "tweets" div when the callback is called but it never gets called. Any help will be really appreciated. Thanks so much.