我想在我的網站上使用雅虎的placefinder找到人的位置,但它不工作。我一定做錯了什麼,但是我無法弄清楚什麼。雅虎與mootools的定位器
我有以下代碼:
new Request.HTML({ method: 'get', url: 'http://where.yahooapis.com/geocode?q=1600+Pennsylvania+Avenue,+Washington,+DC&appid=KGe6P34c',
onSuccess: function() {
console.log("aaa");
}
}).send();
的onSuccess
功能不會被調用。使用螢火蟲,我可以看到請求已發送,並且收到某種迴應。我收到這些響應標頭:
Date: Tue, 23 Aug 2011 09:51:18 GMT
P3P: policyref="http://info.yahoo.com/w3c/p3p.xml", CP="CAO DSP COR CUR ADM DEV TAI PSA PSD IVAi IVDi CONi TELo OTPi OUR DELi SAMi OTRi UNRi PUBi IND PHY ONL UNI PUR FIN COM NAV INT DEM CNT STA POL HEA PRE LOC GOV"
X-Yahoo-Serving-Host: wws2.geotech.ch1.yahoo.com
Access-Control-Allow-Origin: *
Connection: close
Transfer-Encoding: chunked
Content-Type: text/xml; charset=utf-8
Cache-Control: private
但響應的主體是空的。
奇怪的是,如果我在我的網絡瀏覽器中輸入request URL,我會收到一個正常的XML響應。我也在一點使用了提示器服務服務器端,沒有任何問題:
String reqURL = "http://where.yahooapis.com/geocode?postal=" + HttpUtility.UrlEncode(postCode) + "&Country=" + HttpUtility.UrlEncode(countryCode) + "&appid=KGe6P34c";
XmlDocument xml = new XmlDocument();
xml.Load(reqURL);
我在做什麼錯?
哎喲,感謝擡起頭。我只嘗試使用雅虎的服務,因爲谷歌的地理編碼器不適用於我的公司所在的海峽羣島。我想我會尋找另一種解決方案。 – Oliver
這裏是一個JSONP啓用地理位置服務的示例代碼,我傾向於使用:http://jsfiddle.net/dimitar/7KHKF/ –