php rss 取得 ajax

<?php
if(isset($_GET["url"]) && preg_match("/^https?:/",$_GET["url"])){
    $ch = curl_init($_GET["url"]);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
	curl_setopt($ch, CURLOPT_TIMEOUT, 60);
	$data = curl_exec($ch);
	curl_close($ch);
	echo $data;
}else{
    echo "ERROR!";
}
$(document).ready(function(){
	var rssURL = 'http://hoge.com/fuga.rss';
	$.ajax({
		url: 'cdxml.php',
		type: 'GET',
		dataType: 'xml',
		data: {
			url: rssURL
		}
	})
	.done(function(data){
		// console.log(data);
		$(data).find('channel item').each(function(){
			var itemTitle = $(this).find('title').text();
			$('#lists').append('<p>' + itemTitle + '</p>')
		});
	})

	.fail(function(){
		console.log('error');
	});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="http://hoge.com/ajax.js"></script>
<div id="lists"></div>
<channel>
	<item>
		<title>タイトル</title>
	</item>
</channel>
タイトル
PAGE TOP