UPDATE 1:
This is what I get in the browser if I type
http://www.remote_host.com/feed.php?callback=jsonpCallBack
{
"rss": {
"channels": [
{
"title": "title goes here",
"link": "http://www.remote_server.com/feed.php",
"description": "description goes here",
"items": [
{
"title": "item title goes here",
"link": "item link goes here",
"pubDate": "item date goes here",
"description": "item description goes here"
},
{
"title": "item title goes here",
"link": "item link goes here",
"pubDate": "item date goes here",
"description": "item description goes here"
},
{
"title": "item title goes here",
"link": "item link goes here",
"pubDate": "item date goes here",
"description": "item description goes here"
}
]
}
]
}
}
So this is not jsonp?
ORIGINAL QUESTION:
I have the following script where I am trying to get json data from a remote host:
$(document).ready(function() {
get_json_feed();
function get_json_feed() {
$.ajax({
url: 'http://www.remote_host.com/feed.php?type=json',
type: 'GET',
dataType: 'jsonp',
error: function(xhr, status, error) {
alert("error");
},
success: function(json) {
alert("success");
}
});
}
});
But for some reason I am getting an error and warning:
Warning: Resource interpreted as Script but transferred with MIME type text/html.
Error: Uncaught SyntaxError: Unexpected token :
What am I doing wrong?
feed.php?type=jsonpand (b) if the server supports JSONP, it normally accepts a parameter with which you specify the callback name, something like:feed.php?type=jsonp&callback=?. You have to read the documentation of the service you are using.jsonp: 'callback', jsonpCallback: 'jsonpCallback',in ur optionhttp://www.remote_host.com/feed.php?type=jsonin the address bar and the response does not look likefuncName({...})but like{...}, then you get JSON and not JSONP.