GeoNames Home | Postal Codes | Download / Webservice | About 

GeoNames Forum
  [Search] Search   [Recent Topics] Recent Topics   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
script error  XML
Forum Index -> General
Author Message
nicarcola



Joined: 06/02/2007 12:13:27
Messages: 26
Offline

This is my request
request = 'http://ws.geonames.org/findNearbyPlaceNameJSON?lat=' + puntlocatielat + '&lng=' + puntlocatielng + '&callback=getLocation';


This is my callback function
function getLocation(jData) {
if (jData != null) {
var place = jData.geonames[0];
puntstad = place["name"];
puntprovincie = place["adminName1"];
puntland = place["countryName"];
puntlandcode = place["countryCode"];
titel = puntstad+", "+puntprovincie+", "+puntland;
//puntstad = "";
//puntprovincie = jData.adminName1;
//puntland = jData.countryName;
//puntlandcode = jData.countryCode;
//titel = jData.adminName1+", "+jData.countryName;
if (document.getElementById('fadres').value == "") {
puntadres = titel;
}
else {
puntadres = document.getElementById('fadres').value;
}
}
else {
puntstad = "";
puntprovincie = "";
puntland = "";
puntlandcode = "";
titel = "Latitude: "+puntlocatielat+" "+"Longitude: "+puntlocatielng;
}


This is the script error; the lat and lng are in this request in liya; the error is that 'name' is empty or no object.

You can test it with this url
http://www.switchhouses.eu/huizen_bestemming.php

If there is a possibilty to test it before the error oocurs than I am able to catch the error and inform the user in a swooth manner.

Any suugestions?

Nico Oudshoorn.

nicarcola



Joined: 06/02/2007 12:13:27
Messages: 26
Offline

The country where I put the pointer or where the lat and lng came from is Libya.
marc



Joined: 08/12/2005 07:39:47
Messages: 4486
Offline

Hi Nico

I guess your problem has to do with the variable 'place' being null if no result could be found. Why don't you put another if after the assignment of 'place' checking whether it is not null?

Regards

Marc

[WWW]
 
Forum Index -> General
Go to:   
Powered by JForum 2.1.5 © JForum Team