Использование URL:
http://www.remote_host.com/feed.php?callback=jsonpCallback
Я вернусь:
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"
}
]
}
]
} })
На стороне клиента у меня есть следующий скрипт:
$(document).ready(function() {
get_jsonp_feed();
function get_jsonp_feed() {
$.ajax({
url: 'http://www.remote_host.co.uk/feed.php',
type: 'GET',
dataType: 'jsonp',
jsonp: 'callback',
jsonpCallback: 'jsonpCallback',
error: function(xhr, status, error) {
alert("error");
},
success: function(jsonp) {
alert("success");
}
});
}
});
Как записать часть содержимого jsonp на экран, т.е.
channel title: title goes here<br /><br />
item title: title goes here<br />
item link: link goes here<br />
item date: date goes here<br />
item description: description goes here<br /><br />
item title: title goes here<br />
item link: link goes here<br />
item date: date goes here<br />
item description: description goes here<br /><br />
item title: title goes here<br />
item link: link goes here<br />
item date: date goes here<br />
item description: description goes here<br /><br />
вместо предупреждения об «успехе»?