Created
July 24, 2017 18:49
-
-
Save anonymous/a057b324ec159123477e61b94d8375ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Функиция которая читает и записывает в куки | |
<script> | |
function checkCountry() { | |
var country = $.cookie("ad_country"); | |
if ( country === undefined || country === "error" ) { | |
$.jsonp({ | |
type: "GET", | |
url: "http://ipinfo.io", | |
callbackParameter: 'callback', | |
dataType: "jsonp", | |
timeout: 10000, | |
success: function(json){ | |
$.cookie("ad_country", json.country, {expires: 7} ); | |
}, | |
error: function(){ | |
$.cookie("ad_country", "error", {expires: 7} ); | |
} | |
}); | |
} | |
return country; | |
}; | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment