3
I would like to know a php library that would help me with the location of the user access by IP, well I found one on the internet and even worked well (did not show exactly the location) only a 50 km difference but at least can to know the access city! up to here blz, however this application uses the site http://www.geoplugin.net/ To get the information, if, I load the page bringing the ip, shows the data perfectly but if I put to bring the information at the time when my Ajax is storing the informed in the bank, he error! does not load the link to bring the ip info!
Does anyone know any other method? library or article to help me ? or better someone knows how to explain why php with ajax does not load the link to the variables by?
echo "Geolocation results for {$geoplugin->ip}: <br />\n".
"City: {$geoplugin->city} <br />\n".
"Region: {$geoplugin->region} <br />\n".
"Area Code: {$geoplugin->areaCode} <br />\n".
"DMA Code: {$geoplugin->dmaCode} <br />\n".
"Country Name: {$geoplugin->countryName} <br />\n".
"Country Code: {$geoplugin->countryCode} <br />\n".
"Longitude: {$geoplugin->longitude} <br />\n".
"Latitude: {$geoplugin->latitude} <br />\n".
"Currency Code: {$geoplugin->currencyCode} <br />\n".
"Currency Symbol: {$geoplugin->currencySymbol} <br />\n".
"Exchange Rate: {$geoplugin->currencyConverter} <br />\n";
the geoplugin class already charges ip altomatically then need not create variable for that, only ask the infomraçoes
The only way in the front end, with javascript (Ajax) to get data from a site that can another domain, is if it provides data in JSONP format.
– mau humor
The site can also "declare" in response to the request that accepts this type of request. But it seems that is not your case. Still, if possible, put the code.
– mau humor
But what doesn’t work is the ajax request? Or the server side, php?
– Miguel
Miguel, I think it is something on the server side, because when I try to load the page ip.php , everything works perfect, but when I use ajax, the page ip.php should load the information of ip and put the variables right away in the bank but it does not do this with ajax, bad mood, I think I’ll try to bring the data via json to see if right, I’ll try to post the scrip for you to see
– Jonnys J.
Any error message on the console to confirm if it is a CORS protection issue?
– mrlew
good people, I could not solve the problem, the solution was: as soon as the user loads page, in two inputs Hidden loads the information in this case, and then I take this information with ajax
– Jonnys J.
I have already used this configurable Bundle by Composer: https://github.com/aferrandini/Maxmind-GeoIp
– Bernardo
Friend, I use the IP-API which is a great library that returns in JSON, CSV, XML, accepts AJAX requests, and accepts up to 150 requests per minute for the same IP. I hope I’ve helped!
– fabionvs