javascript - Ajax using jquery works on IE but not Firefox -


my end goal have home page pulls rss feeds , displays them on home page personal website. done client side , i'm not looking build server site script (i though if no other way possible).

below page load code. (i don't think problem area nice see starting point)

 $(document).ready(function () { // here     loadpagef(); //<- problems in function      getbackground(document.body); //this messes css of site });  function loadpagef() {     addtablefeed("http://www.npr.org/rss/rss.php?id=1001");     addtablefeed("http://news.yahoo.com/rss/odd");     addtablefeed("http://www.nfl.com/rss/rsslanding?searchstring=team&abbr=dal");     addtablefeed("http://www.npr.org/rss/rss.php?id=1007");       $(".mainarea").css("width",$("iframe").length * (270));  } //this function sets rss data place after formatting  function addtablefeed(feedlink) {      var numofcell = maintb.getelementsbytagname("iframe").length;       maintb.innerhtml += "<iframe id='f" + numofcell + "' class='iframefeed'></iframe>";      getrssfeed(feedlink, "f" + numofcell);  } 

this code calls function each rss add , iframe , passes iframe id , url function (shown below , 99% sure problem) getting data.

 function getrssfeed(feedlink, iframeid) {        /*var xmlhttp; old way did below realizing did not work in firefox      if (window.xmlhttprequest) {// code ie7+, firefox, chrome, opera, safari         xmlhttp = new xmlhttprequest();     }     else {// code ie6, ie5         xmlhttp = new activexobject("microsoft.xmlhttp");     }    xmlhttp.onreadystatechange = function () {         if (xmlhttp.readystate == 4 && xmlhttp.status == 200) {              var hold = xmlhttp.responsetext             loaddata(hold, iframeid);         }     }     xmlhttp.open("get", feedlink, false);     xmlhttp.send();*/ //end of old way      //new way try use json of course failing @ in goal     $.ajax({         type: "get",         url: feedlink,         async: true,         datatype: "text",             success: function(data){             loaddata(data, iframeid);         },         error: function(data, statuscode) {             alert("error: "+data.error)         }      });} 

the function loaddata works fine when called, not called yahoo.com , nfl.com feed. instead alert shown below.

    //note has transcribe dialog box there may errors     error: function () {      if( list ) {         // first, save current length         var start = list length;         (function add( args ) {             jquery.each( args, function( _, arg ) {                 ¡f( jquery.isfunction( arg ) && (!options unique || self.has( arg)                     list .push( arg);                 else if( arg  && arg.length ) {                     // inspect recursively                     add( arg);                 }                 });             })( arguments);             //do need add callbacks             // current firing batch?             if (firing ) (                 firinglength = list length;             //wiih memory, if we’re not firing             // should call right away             j else if ( memory ) (                 firingstart = start;                 fire( memory); 

just in case needed, below load data code.

function loaddata(xml, ifid) {     var htmlstr;     var artcount = 0;      var $xml = $($.parsexml(xml));     $("#" + ifid)[0].contentdocument.open();     $("#" + ifid)[0].contentdocument.close();     $("#" + ifid)[0].contentdocument.write("<head><link rel='stylesheet' type='text/css' href='" + document.getelementbyid("stylesheet").href + "' /></head>");     //rss 2.0 handler   $xml.find("channel item").each(function () {          var $article = $(this);         var title = $article.find("title").text();         var description = $article.find("description").text();         var link = $article.find("link").text();         var pubdate = $article.find("pubdate").text();         htmlstr = "<div id='" + artcount + "span" + ifid + "' class='articalhead'><h3>" + title + "</h3></div>\n";         htmlstr += "<div class='articalbody' id='" + artcount + "div" + ifid + "'>\n";         htmlstr += "\t<p>" + description + "</p><a href='" + link + "' target='_blank' > click here more </a>\n";         htmlstr += "\t<h6>" + pubdate + "</h6><br />\n";         htmlstr += "</div>\n"           $("#" + ifid)[0].contentdocument.write(htmlstr);           $("#" + ifid).contents().find("#" +artcount + "span" + ifid).click(function () {              $("#" + ifid).contents().find("#" + $(this).attr("id").replace("span", "div")).toggle();         });         artcount++;     });      //atom 1.0 handler     $xml.find("feed entry").each(function () {          var $article = $(this);         var title = $article.find("title").text();         var description = $article.find("summary").text();         var link = $article.find("link").attr("href");         var pubdate = $article.find("published").text();         htmlstr = "<div id='" + artcount + "span" + ifid + "' class='articalhead'><h3>" + title + "</h3></div>\n";         htmlstr += "<div class='articalbody' id='" + artcount + "div" + ifid + "'>\n";         htmlstr += "\t<p>" + description + "</p><a href='" + link + "' target='_blank' > click here more </a>\n";         htmlstr += "\t<h6>" + pubdate + "</h6><br />\n";         htmlstr += "</div>\n"           $("#" + ifid)[0].contentdocument.write(htmlstr);          $("#" + ifid).contents().find("#" + artcount + "span" + ifid).click(function () {             $("#" + ifid).contents().find("#" + $(this).attr("id").replace("span", "div")).toggle();         });         artcount++;     });     //$("#" + ifid).contents().find(".articalbody").hide();  } 

please forgive me typos or spelling errors. can post whole web page if needed.


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -