Hi, This is because you cannot do cross domain XHR call. The same origin policy limits AJAX call to only it's own host domain, so foo.com can only AJAX data from foo.com but not from bar.com. With that said, Google Data API has released a JavaScript client library that has built-in technology that overcomes the same origin policy limitation to allow cross domain communciation. Please check it out with this link -
http://code.google.com/apis/calendar/developers_guide_js.html Hope it helps, Austin On Thu, Feb 21, 2008 at 3:24 PM, Joseph <[EMAIL PROTECTED]> wrote: > > Hello, > > I wrote some client-side scripting with javascript that uses the > XMLHTTPREQUEST object to fetch xml and format it. It works really well > in handling Google data if the file is saved with an XML file > extension, but for some reason I cannot get it to get the data when i > directly use the XML address provided by google. > > Here is the address i'm using: > > http://www.google.com/calendar/feeds/[EMAIL PROTECTED]/public/basic > > when i load up the page it attempts to save as a basic file (no file > extension). How do i go about getting the XML raw from google using > javascript? Do i have to change my approach of using the > xmlhttprequest object? > > thanx > > here is a sample of the code i'm using: > > <code> > function loadRSS(rssfile, divSrc, isGoogleCalendar) > { > //dimension the AJAX > if (window.ActiveXObject) //IE > xhr = new ActiveXObject("Microsoft.XMLHTTP"); > else if (window.XMLHttpRequest) //other > xhr = new XMLHttpRequest(); > else > { > divSrc.innerHTML="Your browser does not support RSS"; //cancel > request > return false; > } > //open the xml file > xhr.open("GET",rssfile,true); > > xhr.setRequestHeader("Cache-Control", "no-cache"); > xhr.setRequestHeader("Pragma", "no-cache"); > > xhr.onreadystatechange = function() > { > > if (xhr.readyState == 4) //document loaded > { > if (xhr.status == 200) //active page/conection > { > var chk = new String; > chk = xhr.responseText; > if (xhr.responseText != null) //is file empty > { > if (chk.indexOf("<?xml") >= 0 && > chk.indexOf("<?xml") < 5) // > make sure file is valid xml > { > if (isGoogleCalendar==true) > processGoogle( > xhr.responseXML, divSrc); > else > processRSS( > xhr.responseXML, divSrc); > } > } > else > divSrc.innerHTML="Error Retrieving Data"; > } > else > divSrc.style.display = "none"; //no data to > display > } > > } > xhr.send(null); > }</code> > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Calendar Data API" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/google-calendar-help-dataapi?hl=en -~----------~----~----~----~------~----~------~--~---
