Created
March 19, 2015 21:07
-
-
Save danpecher/55ead2f5f937c243b6ba 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
var app = angular.module('test', []); | |
app.controller('MainController', function($scope, $http){ | |
$scope.formData = { | |
'first_name': '', | |
'last_name': '' | |
}; | |
$scope.submitHandler = function() { | |
$http({ | |
method : 'POST', | |
url : 'script.php', | |
data : $.param($scope.formData), | |
headers : { 'Content-Type': 'application/x-www-form-urlencoded' } | |
}).success(function(data){ | |
$scope.result = data; | |
}); | |
} | |
}); |
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
<html ng-app="test"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Document</title> | |
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> | |
</head> | |
<body> | |
<div ng-controller="MainController" class="container"> | |
<div class="col-md-6 col-md-offset-3"> | |
<form ng-submit="submitHandler()"> | |
<input type="text" name="first_name" ng-model="formData.first_name" class="form-control" placeholder="Jmeno"> | |
<input type="text" name="last_name" ng-model="formData.last_name" class="form-control" placeholder="Prijmeni"> | |
<input type="submit" class="btn btn-primary"> | |
</form> | |
Vase cele jmeno je: {{ formData.first_name }} {{ formData.last_name }}<br> | |
Vysledek requestu: {{ result }} | |
</div> | |
</div> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js"></script> | |
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.15/angular.js"></script> | |
<script src="app.js"></script> | |
</body> | |
</html> |
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
<?php | |
echo 'php vraci '. $_REQUEST['first_name'].' '.$_REQUEST['last_name'].' a martin smrdi.'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment