3 messages in com.googlegroups.google-calendar-help-dataapiRe: Working with XML| From | Sent On | Attachments |
|---|---|---|
| Joseph | 21 Feb 2008 15:23 | |
| Austin (Google) | 21 Feb 2008 16:06 | |
| Joseph | 21 Feb 2008 16:50 |
| Subject: | Re: Working with XML![]() |
|---|---|
| From: | Austin (Google) (api....@google.com) |
| Date: | 02/21/2008 04:06:47 PM |
| List: | com.googlegroups.google-calendar-help-dataapi |
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 <kazm...@gmail.com> 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/bapsacramento.org...@group.calendar.google.com/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>




