php - Using AJAX to insert lat/long into SESSION variables not working -


I have a site with directories for those businesses that have links to cities, which users can click and Find businesses near the city.

So far, I have completed the process of using a GET variable on the link and with the PHP and Google Maps API. Unfortunately, the site is starting to generate more than 2500 questions per day, so I tried to use the Javascript API, when YouTube clicks the link and then sets it on the session using AJAX. I thought I was on the right track but it is not working. It seems that either does not work at all, or only after clicking on a link several times the session variable changes

Any ideas?

This is my test page:

ex>

And this is the setLoc.php file:

   

I added the template because I thought every time it makes a difference it makes a difference, but

I was able to get my desired results by using:

  & lt; Script type = "text / javascript" & gt; Function setLoc (lat, lng, address, href) {$ .ajax ({type: 'POST', url: 'setLoc.php', data: {lat: lat, lng: lng, address: address}, success: function () {Location.href = href;}}); } $ ('Loc'). Each (function () {$ (this). (Function (e) {var href = $ (this) .attr ('href'); e.preventDefault (); var address = $ (This) .attr ( 'Id'); var geocoder = new google.maps.Geocoder (); geocoder.geocode ({'address': address + 'FL'}, function (result, status) {var location = result [0] .geometry. Location; var lat = location.lat (); var lng = location.lng (); setLoc (lat, lng, address, href);});});}); & Lt; / Script & gt;  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -