[Chugalug] Any javascript guru's out there?

Joe Freeman joe at netbyjoe.com
Tue Nov 13 22:27:31 UTC 2012


Here's what the EasyjQuery docs show-

[IP] => 93.154.204.205

    [ContinentCode] => NA
    [ContinentName] => North America
    [CountryCode2] => US
    [CountryCode3] => USA
    [COUNTRY] => US
    [CountryName] => United States
    [RegionName] => California
    [CityName] => Garden Grove
    [CityLatitude] => 33.7831
    [CityLongitude] => -118.0271
    [CountryLatitude] => 38
    [CountryLongitude] => -98
    [LocalTimeZone] => America/Los_Angeles
    [REMOTE_ADDR] => 77.93.210.64
    [HTTP_X_FORWARDED_FOR] =>
    [CallingCode] => 1
    [Population] => 307,212,123 (3)
    [AreaSqKm] => 9,826,675 (4)
    [GDP_USD] => 14.26 Trillion (1)
    [Capital] => Washington, D.C.
    [Electrical] => 120 V,60 Hz Type A Type B
    [Languages] => English 82.1%, Spanish 10.7%, other Indo-European
3.8%, Asian and Pacific island 2.7%, other 0.7% (2000 census)
    [Currency] => US Dollar (USD)
    [Flag] => http://api.easyjquery.com/proips/flags/US.jpg


As I said, the alert in the ip_callback function shows valid data, so I
think I'm parsing out the json correctly. It's a question of how do I get
the data out of the callback function into the onLoad function, I think.

On Tue, Nov 13, 2012 at 5:16 PM, Randy Yates <lpcustom at gmail.com> wrote:

> What does the json look like coming back from the request?
>
>
> On Tue, Nov 13, 2012 at 5:13 PM, Joe Freeman <joe at netbyjoe.com> wrote:
>
>> In making my first foray into javascript, I've run into an issue- I'm
>> using EasyjQuery_Get_IP() to get the client ip and some basic geo-location
>> into, which I think pass back using an ajax post to a php script on the
>> server that writes the data to a mysql database.
>>
>> Inside the ip_callback function, my debug screen pop shows the correct
>> output. The screen pop in the onLoad() function, however, doesn't show the
>> correct output - it shows all my variable contents as "undefined". I'm
>> obviously missing something simple and basic to javascript here, so I'm
>> hoping someone can help me out.
>>
>> Thanks-
>> Joe
>>
>> <script type="text/javascript">
>>
>> function ip_callback(json) {
>>
>>         this.ip_addr = json.IP;
>>         this.country = json.Country;
>>         this.city = json.CityName;
>>         this.region =  json.RegionName;
>>         this.remote_ip = json.REMOTE_ADDR;
>>         this.x_forward = json.HTTP_X_FORWARDED_FOR;
>>
>>
>> // debug purposes - trigger screen pop with info
>>           alert("IP:" + this.ip_addr + " Region:" + this.region +"
>> City:"+this.city);
>>
>>    return this;
>> }
>>
>> function onLoad() {
>>
>>   var now = new Date().getTime();
>>
>>   var ip_callback = new ip_callback();
>>   EasyjQuery_Get_IP("ip_callback","full");
>>
>> // debug purposes - trigger screen pop with info
>>   alert("IP:" + ip_callback.ip_addr + " Region:" +ip_callback.region +"
>> City:"+ip_callback.city);
>>
>>   var params = {
>>         'client_region' : ip_callback.region,
>>         'client_city' : ip_callback.city,
>>         'client_ip' : ip_callback.ip_addr,
>>
>>   };
>>
>>   $.ajax({
>>         type: "POST",
>>         url: "<redacted>/cgi-bin/testloadhandler.php",
>>         async: false,
>>         data: params
>>
>>   });
>>
>> }
>>
>> </script>
>>
>> _______________________________________________
>> Chugalug mailing list
>> Chugalug at chugalug.org
>> http://chugalug.org/cgi-bin/mailman/listinfo/chugalug
>>
>>
>
>
> --
> Google reads my email!
>
> _______________________________________________
> Chugalug mailing list
> Chugalug at chugalug.org
> http://chugalug.org/cgi-bin/mailman/listinfo/chugalug
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://chugalug.org/pipermail/chugalug/attachments/20121113/4f2a4326/attachment-0001.html>


More information about the Chugalug mailing list