Skip to content
Advertisement

How to display a dynamic image based on geo location?

I’m trying to display a specific image based on the country the user is visiting my site from. I’ve managed to use ajax and the https://geolocation-db.com/jsonp/ to capture the location information.

If I check this from the US, or any other country, I’m able to output that country (using TunnelBear), but my goal is to display a different image depending on the output country.

What am I missing?

JavaScript
JavaScript

Advertisement

Answer

You need to check the country inside the success method.

JavaScript
JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement