Hello,

I am trying to post my city location automatically when someone update their status. How?

I try this but it does not show anything as it suppose to be:

I follow this tutorial: https://www.sitepoint.com/geolocation-jquery-api-geoplugin/

<script>
jQuery(document).ready(function($) {
    alert("Your location is: " + geoplugin_countryName() + ", " + geoplugin_region() + ", " + geoplugin_city());

    var country = geoplugin_countryName();
    $("#country").append("<option value='1' selected>"+country+"");

    var zone = geoplugin_region();
    $("#zone").append("<option value='1' selected>"+zone+"");

    var district = geoplugin_city();
    $("#district").append("<option value='1' selected>"+district+"");
});

</script>

<div id="country"></div>
<div id="zone"></div>
<div id="district"></div>

I wonder why it does not show my city. How to show the city by using this script?

Recommended Answers

All 2 Replies

Two things.

  1. The locations are in that plugin and may not list your city.

  2. I'm using Opera and VPN so while I'm in the USA, this is what the test page at http://www.geoplugin.com/webservices/javascript returned.

    function geoplugin_request() { return '204.52.135.132';}
    function geoplugin_status() { return '200';}
    function geoplugin_credit() { return 'Some of the returned data includes GeoLite data created by MaxMind, available from <a href=\'http://www.maxmind.com\'>http://www.maxmind.com</a>.';}
    function geoplugin_city() { return 'Toronto';}
    function geoplugin_region() { return 'ON';}
    function geoplugin_regionCode() { return 'ON';}
    function geoplugin_regionName() { return 'Ontario';}
    function geoplugin_areaCode() { return '0';}
    function geoplugin_dmaCode() { return '0';}
    function geoplugin_countryCode() { return 'CA';}
    function geoplugin_countryName() { return 'Canada';}
    function geoplugin_continentCode() { return 'NA';}
    function geoplugin_latitude() { return '43.6437';}
    function geoplugin_longitude() { return '-79.3787';}
    function geoplugin_currencyCode() { return 'CAD';}
    function geoplugin_currencySymbol() { return '$';}
    function geoplugin_currencySymbol_UTF8() { return '$';}
    function geoplugin_currencyConverter(amt, symbol) {
    if (!amt) { return false; }
    var converted = amt 1.3458;
    if (converted <0) { return false; }
    if (symbol === false) { return Math.round(converted
    100)/100; }
    else { return '$'+(Math.round(converted * 100)/100);}
    return false;
    }

There it is. This plugin did not find me. I proved it so why spend another minute on this?

Do you have a link to the CDN for jquery? What does your console output say?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.