[Chugalug] Any javascript guru's out there?
Randy Yates
lpcustom at gmail.com
Tue Nov 13 22:16:55 UTC 2012
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!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://chugalug.org/pipermail/chugalug/attachments/20121113/8c99e4fc/attachment.html>
More information about the Chugalug
mailing list