名前: maeda 送信 Hello, maeda ! |
![]()
<?php print "Hello PHP 漢字テスト(Shift-Jis)"; ?> |
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>XML Http</title>
</head>
<body>
<h2>Using the XMLHttpRequest Object</h2>
<div id="demo">
<button type="button" onclick="loadXMLDoc()">Change Content</button>
</div>
<script>
function loadXMLDoc()
{ var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{ if (this.readyState == 4 && this.status == 200)
{ document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "../php/hello.php", true);
xhttp.send();
}
</script>
</body>
</html>
|
<div id="demo"> <button type="button" onclick="loadXMLDoc()">Change Content</button> </div> |
<script>
function loadXMLDoc()
{ var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function()
{ if (this.readyState == 4 && this.status == 200)
{ document.getElementById("demo").innerHTML =
this.responseText;
}
};
xhttp.open("GET", "../php/hello.php", true);
xhttp.send();
}
</script>
|
![]()
<?php
$data= $_GET["name"];
if (!isset($data)) $data = "name Error";
print "Hello, $data !";
?>
|
<a href="http://maedakobe.rw.xsi.jp/javascript/http.php?name=maeda">http.php のテスト</a> |
![]()
<!doctype html>
<html ng-app="myApp">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.4/angular.min.js"></script>
<script>
angular.module('myApp', [])
.controller('MyController', ['$scope', '$http', function($scope, $http)
{ $scope.onclick = function()
{ // サーバーに対してリクエストを送信
$http(
{ method: 'GET',
url: 'http.php',
params: { name: $scope.name }
})
// 成功時の処理(ページにあいさつメッセージを反映)
.success(function(data, status, headers, config)
{ $scope.result = data;
})
// 失敗時の処理(ページにエラーメッセージを反映)
.error(function(data, status, headers, config)
{ $scope.result = '通信失敗!';
});
};
}]);
</script>
</head>
<body>
<body ng-controller="MyController">
<form name="myForm" novalidate>
<label for="name">名前:</label>
<input id="name" name="name" type="text" ng-model="name" />
<button ng-click="onclick()">送信</button>
</form>
<div>{{result}}</div>
</body>
</html>
|
angular.module('myApp', [])
.controller('MyController', ['$scope', '$http', function($scope, $http)
{ $scope.onclick = function()
{ // サーバーに対してリクエストを送信
$http(
{ method: 'GET',
url: 'http.php',
params: { name: $scope.name }
})
// 成功時の処理(ページにあいさつメッセージを反映)
.success(function(data, status, headers, config)
{ $scope.result = data;
})
// 失敗時の処理(ページにエラーメッセージを反映)
.error(function(data, status, headers, config)
{ $scope.result = '通信失敗!';
});
};
}]);
|
<form name="myForm" novalidate> <label for="name">名前:</label> <input id="name" name="name" type="text" ng-model="name" /> <button ng-click="onclick()">送信</button> </form> |
![]()