0

Developing Geoplanet on localhost

Is it possible to develop a Geoplanet application using an appid registered for a local webserver running as \\localhost? I have registered an appid for http://localhost and when I try to call the service from JavaScript embedded onto the page, I get the following error:
Security Error: Content at http://localhost/.../geoplanet_test.php may not load data from http://where.yahooapis.com/v1/places.q(pla...n&appid=nnn.

I have also tried with an appid registered for the full path to the php page which the test code loads from.

Thanks

by
2 Replies
  • More info on this - I've now realised that the problem is not developing on localhost, but calling the Geoplanet URL from JavaScript running in the browser. It seems that whilst my API key works fine for redirection to the geoplanet response, I cannot call the URL using JavaScript to process the response. I am using the JQuery library to do this. Here's the code I am using to test this:

    CODE
    var appid='xxx';
    var request = 'http://where.yahooapis.com/v1/places.q("' +
    document.placeform.place.value + '",uk)';
    $.get(request, {'format': 'json', 'appid': appid}, function(data){
    alert("Data Loaded: " + data);
    });


    Any help would be gratefully recieved!

    John
    0
  • The JQuery $.get function cannot be used for cross-domain loads. You need to use $.getJSON. Here is an example call:

    CODE
    $.getJSON(request + '?format=json&appid=' + appid + '&callback=?', function(data){ alert("Data Loaded:" + data);


    To see the response in a structured view, you can use a dump function like http://www.openjs.com/scripts/others/dump_...php_print_r.php. Just insert the dump code in your application and replace "data" with "dump(data)" in the alert call.

    A few more suggestions:
    1) Do not use double quotes to enclose your search query; use single quotes
    2) Focus codes are iso-3166 country codes; 'gb' is the code for United Kingdom

    Eddie Babcock
    Yahoo! Geographic Technologies

    QUOTE (vanbreda_john @ Jan 14 2009, 02:34 AM) <{POST_SNAPBACK}>
    More info on this - I've now realised that the problem is not developing on localhost, but calling the Geoplanet URL from JavaScript running in the browser. It seems that whilst my API key works fine for redirection to the geoplanet response, I cannot call the URL using JavaScript to process the response. I am using the JQuery library to do this. Here's the code I am using to test this:

    CODE
    var appid='xxx';
    var request = 'http://where.yahooapis.com/v1/places.q("' +
    document.placeform.place.value + '",uk)';
    $.get(request, {'format': 'json', 'appid': appid}, function(data){
    alert("Data Loaded: " + data);
    });


    Any help would be gratefully recieved!

    John
    0
This forum is locked.

Recent Posts

in GeoPlanet General Discussion