Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Getting country from IP address using JQuery

Hi all

This is one that I thought I'd solved, thanks to Brian McEwen pointing me in the right direction.  However, since upgrading to 8.3.10, the country bit doesn't seem to work anymore.  The language bit still works though.

Can anyone spot anything obvious? My javascript and jquery knowledge ain't very good ...

<input name="GeoData_country" id="GeoData_country" type="hidden">
<input name="GeoData_language" id="GeoData_language" type="hidden">

<script type="text/javascript">
$.getJSON('http://api.wipmania.com/jsonp?callback=?', function (data) { 
     
    var country = data.address.country;
     
    jQuery('#GeoData_country').val(country);
 
}); //EO document ready
</script>

<script type="text/javascript">
{ 
     
    var userLang = navigator.language || navigator.userLanguage;
     
    jQuery('#GeoData_language').val(userLang);
 
}; //EO document ready
</script>
related to an answer for: Language, Location and Captcha
asked Feb 18, 2015 by Marion Bronze (3,435 points)
It looks like wipmania has a contact form that mails to mail@wipmania.com.  I wonder if they might be able to help with the JSON call?

1 Answer

0 votes
I run your code it raise 3 errors......

ReferenceError: $ is not defined

ReferenceError: jQuery is not defined

The character encoding of the HTML document was not declared. The document will render with garbled text in some browser configurations if the document contains characters from outside the US-ASCII range. The character encoding of the page must be declared in the document or in the transfer protocol.
answered May 12, 2015 by anonymous
...