I want to send data coming from a php function to my HTML page using AJAX, my function look like:
function getFeed() {
$url = 'http://feeds.bbci.co.uk/news/rss.xml?edition=int#';
$content = file_get_contents($url);
$data = simplexml_load_string($content);
$articles= array();
foreach( $data->channel->item as $item){
$articles[]=array(
'title' => (string)$item->title,
'description' => (string)$item->description,
'link' => (string)$item->link,
'Date' => (string)$item->pubDate,
);
}
foreach($articles as $article){
echo json_encode($article['title']);
}
}
my javascript script look like:
$(function(){
$.ajax({
type:'GET',
url: '/rss/core/inc/rssnews.inc.php',
success: function (data){
console.log('success',data);
}
});
});
Once I execute the code, I get a 'success' message in the console, but not the data.
So, how can I get the JSON data in this case?

getFeedafter defining it ?json_encode($articles)