Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- json headache


Fotiman - 3:33 pm on Feb 20, 2012 (gmt 0)


In this case, I would simply not use an anonymous function. Instead, give your function a name and call it like so:


$('#find').click(function(){
bounds = google.maps.Polygon.prototype.getBounds();
north = bounds.getNorthEast().lng();
south = bounds.getSouthWest().lng();
west = bounds.getSouthWest().lat();
east = bounds.getNorthEast().lat();
//console.log(north);
//console.log(south);
//console.log(west);
//console.log(east);
function getPostCodes(data){
if(!data) {
north = north + 0.00002;
south = south - 0.00002;
west = west - 0.00002;
east = east + 0.00002;
//need to run get json again!
$.getJSON('/properties/search/get-postcodes-in-area/north/'+north+'/south/'+south+'/west/'+west+'/east/'+east, getPostCodes);
return;
}
// If you make it here, you've got your result!
}
$.getJSON('/properties/search/get-postcodes-in-area/north/'+north+'/south/'+south+'/west/'+west+'/east/'+east, getPostCodes);
});


Thread source:: http://www.webmasterworld.com/javascript/4419536.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com