Skip to content

Instantly share code, notes, and snippets.

@nabettu
Created September 25, 2015 08:51
Show Gist options
  • Save nabettu/29b0e27ecec7361c724f to your computer and use it in GitHub Desktop.
Save nabettu/29b0e27ecec7361c724f to your computer and use it in GitHub Desktop.
サーバーにおいておいてipaddressを返すphp
<?php
header("Content-type: application/x-javascript");
header("Access-Control-Allow-Origin:*");
$ip_address = $_SERVER['REMOTE_ADDR'];
echo "var ipAddress = '" . $ip_address . "';";
?>
@nabettu
Copy link
Author

nabettu commented Sep 25, 2015

$.ajax({
type: "GET",
url:"PHPファイルのアドレス",
success: function() {
console.log(ipAddress);
},
error: function() {
console.log('error');
}
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment