Sunday, February 14, 2016

AJAX-PHP Vs Angular JS



AJAX PHP working like Angular JS


HTML

<html>
<head>
<script src="jquery.js" ></script>
<script>
function angu(value){
$.ajax({
type:"GET",
url:"data.php?name="+value,
success:function(data){
    $("#get").html(data);
}
});
}
</script>
</head>
<body>
<input type="text" onkeyup="angu(this.value);" />
<div id="get"></div>
</body>
</html>


PHP

<?php
$name=$_GET['name'];
echo $name;
?>


full source code:

https://drive.google.com/file/d/0B0vD4EvPj_p7TjJ1RlpXUlFmMGc/view?usp=sharing



ANGULAR JS


<!DOCTYPE html>
<html>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
<body>

<div ng-app="myApp" ng-controller="myCtrl">
Name: <input ng-model="name">
<h1>{{name}}</h1>
</div>

<script>
var app = angular.module('myApp', []);
app.controller('myCtrl', function($scope) {
    $scope.name = "Dharambir Singh";
});
</script>
</body>
</html>



No comments:

Post a Comment

Dharamart.blogspot.in