I am relatively new to javascript and I am facing some difficulty.I have two java script files as I have shown below. I am having trouble getting the value of the variable entry_title inside the getRss function and storing it inside the variables Rss1_title and Rss2_title . Creating a global variable and assigning it to entry_title will make things worse as I will not be able to know from which Rss url the title came from. Is there a easy way to get the value of the callback functions ?
<script type="text/javascript" src="jsRss.js"></script> <script type="text/javascript" src="notification.js"></script>
My notification.js file
function get_rss1_feeds(){ var Rss1_title = getRss("http://yofreesamples.com/category/free-coupons/feed/?type=rss"); } function get_rss2_feeds(){ var Rss2_title = getRss("http://yofreesamples.com/category/real-freebies/feed/?type=rss"); } setTimeout('get_rss1_feeds()',8000); setTimeout('get_rss2_feeds()',7000);
My jsRss.js file:
function getRss(url){ if(url == null) return false; google.load("feeds", "1"); // Our callback function, for when a feed is loaded. function feedLoaded(result) { if (!result.error) { var entry = result.feed.entries[0]; var entry_title = entry.title; // need to get this value } } function Load() { // Create a feed instance that will grab feed. var feed = new google.feeds.Feed(url); // Calling load sends the request off. It requires a callback function. feed.load(feedLoaded); } google.setOnLoadCallback(Load); }
Errors :
When the setTimeout(get_rss1_feeds, 8000); method is called I get a blank screen. I get a error in my console saying octal literals and octal escape sequences are deprecated and it is pointing to the 6th line in this script. Is it because I am using google-api for parsing my Rss?
if (window['google'] != undefined && window['google']['loader'] != undefined) { if (!window['google']['feeds']) { window['google']['feeds'] = {}; google.feeds.Version = '1.0'; google.feeds.JSHash = '8992c0a2cdf258e5bd0f517c78243cd6'; google.feeds.LoadArgs = 'file\75feeds\46v\0751'; } google.loader.writeLoadTag("css", google.loader.ServiceBase + "/api/feeds/1.0/8992c0a2cdf258e5bd0f517c78243cd6/default+en.css", false); google.loader.writeLoadTag("script", google.loader.ServiceBase + "/api/feeds/1.0/8992c0a2cdf258e5bd0f517c78243cd6/default+en.I.js", false); }