It appears that you are running into a same-origin policy issue in Firefox (see
https://developer.mozilla.org/en/Same_origi..._for_JavaScript for more information). Firefox does not allow JavaScript code to request XML resources from domains other than the one hosting the JavaScript code. IE appears to be more lax with XML requests that come from JavaScript code contained in local files.
Firefox 3.5 and above supports a proposed W3C cross-origin resource sharing mechanism (see
http://www.w3.org/TR/cors/ for more information), but GeoPlanet does not yet support this mechanism. I will have this added to our product enhancement list.
GeoPlanet supports JSONP (see
http://ajaxian.com/archives/jsonp-json-with-padding), which effectively allows you to treat GeoPlanet like a JavaScript function call. JavaScript frameworks like JQuery (see
http://api.jquery.com/jQuery.getJSON/ for more information) and YUI (see
http://yuilibrary.com/gallery/show/jsonp for more information) allow you to easily integrate JSONP into your application.
Eddie Babcock
Yahoo! Geographic Technologies
Hi,
I am facing this peculiar issue in Mozilla Firefox 3.5.7, when i fire a AJAX request to the GEOPlanet URL:
var url = 'http://where.yahooapis.com/v1/places.q('+elem+');start=0;count=10?appid=<appid>';
the "elem" here is an input element.
The Javascript for the XMLHTTP is as follows:
if (window.XMLHttpRequest)
{// code for IE7, Firefox, Mozilla, etc.
xmlhttp=new XMLHttpRequest();
}
else if (window.ActiveXObject)
{// code for IE5, IE6
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
if (xmlhttp!=null)
{
xmlhttp.onreadystatechange=onResponse;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
else
{
alert("Your browser does not support XMLHTTP.");
}
The call back has following implementation:
function onResponse()
{
if(xmlhttp.readyState!=4) return;
alert("Status:"+xmlhttp.status);
alert("StatusText:"+xmlhttp.statusText);
if(xmlhttp.status!=200)
{
alert("Problem retrieving XML data");
return;
}
----
---
}
I get alerts as
Status:0
Status Text:Ok
and
Problem retrieving XML data
The same code though works on IE 7
Kindly help me with this issue.
TIA
Regards,
Sidharth