Created
September 25, 2015 08:51
-
-
Save nabettu/29b0e27ecec7361c724f to your computer and use it in GitHub Desktop.
サーバーにおいておいてipaddressを返すphp
This file contains hidden or 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
<?php | |
header("Content-type: application/x-javascript"); | |
header("Access-Control-Allow-Origin:*"); | |
$ip_address = $_SERVER['REMOTE_ADDR']; | |
echo "var ipAddress = '" . $ip_address . "';"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
$.ajax({
type: "GET",
url:"PHPファイルのアドレス",
success: function() {
console.log(ipAddress);
},
error: function() {
console.log('error');
}
});