Angular http POST pass Multiple Parameters PHP MySQLi
Today, We want to share with you Angular http POST pass Multiple Parameters PHP MySQLi.
In this post we will show you Angularjs pass multiple parameters to $http post, hear for AngularJS Http Post Method ($http.post) with Parameters Example we will give you demo and example for implement.
In this post, we will learn about AngularJS: $http POST example with Parameters with an example.
Angularjs Simple pass data parameters value to (client side to server side)$http post – Data in $http.post method used to request method are data passed in params value which are data posted to server side.
The $http method service is a core simple Angular service that functionality with communication with the remote data HTTP servers via all the browser’s data value XMLHttpRequest via object or via JSONP data value.
Basic Response Param
[php]
1. config – The pass a configuration(content type) object is used to generate(leep active) the request.
2. data – It is a return either string value or an object data.
3. headers – We able to get all the header information data.
4. status – We can get all the HTTP status(Like 200,201,400,etc..) code of the response data.
5. statusText – we can get the all HTTP status text of the response data.
[/php]
syntax
[php]
var url_str=””;
$http.post(url_str, {
params: { paramname1: value1, paramname2:value2, paramname3:value3…… }
});
[/php]
Example : Simple pass parameter and value in Angularjs using $http.post
[php]
$http.post(“www.infinityknow.com/do_fetchdata.php”, {
params: { id: ‘9898’, name:’angularking’, email:’admin@infinityknow.com’ }
});
[/php]
Example 2 : send POST in angularjs with multiple params.
[php]
var data_valu = { id: ‘9898’, name:’angularking’, email:’admin@infinityknow.com’}
$http({
url: “www.infinityknow.com/do_fetchdata.php”,
method: “POST”,
params: data_valu
})
[/php]
Example 3 :display username authentication in angularjs using Post Method
[php]
$http.post(‘http://infinityknow.com/api/auth/login’,data)
.success(function(msg) {
var uid=msg.SessionId;
var uname=msg.UserName;
if(uid)
{
$scope.msgtxt=uname;
})
.error(function(data, status) {
$scope.msgtxt=data.ResponseStatus.Message;
});
[/php]
Example 4 : Full source code : $http.post server request in AngularJS
[php]
var infinityknowApp = angular.module(“infinityknowApp”, []);
infinityknowApp.controller(“infinityknowhttpCtrl”, function ($scope, $http) {
$scope.LoginData = function () {
var dataval = $.param({
usersalesemailid: $scope.usersalesemailid,
userlpass: $scope.userlpass
});
var configheader = {
headers : { //pass headers
‘Content-Type’: // like authentication/json,etc.. ‘application/x-www-form-urlencoded;charset=utf-8;’
}
}
$http.post(‘http://infinityknow.com/api/auth/login’, dataval, configheader)
.success(function (dataresults, status, headers, config) {
$scope.PostDataResponse = dataresults;
})
.error(function (dataresults, status, header, config) {
$scope.alldatavalueresopnseresult = “Results: ” + dataresults +
“
Value of status: ” + status +
“
headers value : ” + header +
“
config value : ” + config;
});
};
});
[/php]