javascript - Check if Cross Domain RSS has changed using Ajax -


i have website loads rss news feed http://www.tagesschau.de/xml/rss2

i want check every 60 seconds if rss feed has been updated. if has changed should reload rss feed. ajax thought work great, though stuck here:

<script type="text/javascript" src="../js/jquery.ajax-cross-origin.min.js"></script> <script type="text/javascript"> function checkrss() {  $.ajax({   crossorigin: true,   type: 'get',   proxy: "../php/proxy.php",   url: "http://www.tagesschau.de/xml/rss2",   datatype: "xml",   success: function (xml) {    //console.log(xml);   },   error: function(xml) {    console.log(xml);   }  }); } setinterval("checkrss()", 60000); </script> 

(i commented success event console.log see if ajax trigger success or error event. triggered error event.)

in console status: 200, readystate: 4 , statustext: "success".

does know why error event triggered? checked url through http://jsonlint.com. load list gives me error. problem?

ajax-cross-origin plugin: http://www.ajax-cross-origin.com/how.html#js-what-is-this-plugin

edit

i added proxy php file ajax-cross-origin plugin (and added link in ajax code above):

<?php $url = (isset($_get['url'])) ? $_get['url'] : false; if(!$url) exit;  $referer = (isset($_server['http_referer'])) ? strtolower($_server['http_referer']) : false; $is_allowed = $referer && strpos($referer, strtolower($_server['server_name'])) !== false;  $string = ($is_allowed) ? utf8_encode(file_get_contents($url)) : 'you not allowed use proxy!'; $json = json_encode($string); $callback = (isset($_get['callback'])) ? $_get['callback'] : false; if($callback){     $jsonp = "$callback($json)";     header('content-type: application/javascript');     echo $jsonp;     exit; } echo $json; ?> 

maybe stupid question, should change http_referer , server_name something?

what happens success event triggered -yes!- outcome of log contains nothing more " ".

cross site scripting policies make tricky... best bet use 3rd party api such superfeedr or google feed api. benefit of they handle load , still able retrieve updates original feed pretty quickly.


Comments