Hi all,
I'm trying to use Django and especially GeoDjango so I made a "little
application" where a country is randomly proposed and the user must
select it on the map (http://www.geotests.net/geogame/).
When the user select the country on the map an ajax request is send by
the application and call a function of my views.
Everything works fine when I use it with the django server. But when I
tried to do the same with apache mod-python, the ajax call return me
the actual page.
I think i've got maybe a problem with the url rewriting...
Do you know what i'm doing wrong?
Here is my ajax call :
JavaScript :
var url = './getName?';
var country = $('randomCountryName').innerHTML;
XY = map.getLonLatFromPixel(new OpenLayers.Pixel
(evt.xy.x, evt.xy.y));
url += 'x='+XY.lon;
url += '&y='+XY.lat;
url += '&tryCountry='+tryCountry;
url += '&country='+country;
new OpenLayers.Request.GET({
url : url,
success: responseCountry
});
And the view :
def getName(req) :
#Geos Point geometry
pnt = Point(float(req.GET['x']), float(req.GET['y']))
response = {}
if int(req.GET['tryCountry']) == 1 :
newCountry = newName(req.GET['country'])
response['newCountry'] = newCountry.name
response['X'] = newCountry.geom.centroid.x
response['Y'] = newCountry.geom.centroid.y
try :
country = WorldBorders.objects.get(geom__intersects=pnt)
if country.name != req.GET['country'] :
response['result'] = "false"
else :
newCountry = newName(country.name)
response['newCountry'] = newCountry.name
response['X'] = newCountry.geom.centroid.x
response['Y'] = newCountry.geom.centroid.y
response['result'] = "true"
except :
response['result'] = "false"
# Return a json object
return HttpResponse(simplejson.dumps
(response),mimetype="application/javascript")
Thanks for any help
Regards
Arnaud
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---