I am building a BlogApp and I am stuck on a Problem.
What i am trying to do
I am trying to access user location like :- City or State. I don't want to access in Map. I just want to access the city name of users.
What have i tried
I try through
JavaScript
andGoogle Apis
to access location , It showed the location perfectly. BUT i didn't find any way to save the location of User in Database from FrontEnd to BackEnd. So i dropped down that method. The Below ↓ code is showing theFrontEnd Code of JavaScript
.<script> let thisElement = $(this) $.ajax({ url: "https://geolocation-db.com/jsonp","/update_counter/", jsonpCallback: "callback", dataType: "jsonp", success: function(location) { $('#country').html(location.country_name); console.log('success') thisElement.parent().parent().fadeOut(); } }); </script> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script> <div>Country: <span id="country"></span></div>
Then i tried
MaxMind's GeoIP
it also didn't work for me. ( Also answers are too Old ).Then i tried THIS BUT they are not connected to any model, so it may be difficult to save user location in DataBase.
I don't know what to do.
Any help would be appreciated.
Thank You in Advance.