Angular http POST pass Multiple Parameters PHP MySQLi

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

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.

syntax

var url_str="";
$http.post(url_str, {
    params: { paramname1: value1, paramname2:value2, paramname3:value3...... }
});

Example : Simple pass parameter and value in Angularjs using $http.post

$http.post("www.infinityknow.com/do_fetchdata.php", {
    params: { id: '9898', name:'angularking', email:'[email protected]' }
});

Example 2 : send POST in angularjs with multiple params.

var data_valu = { id: '9898', name:'angularking', email:'[email protected]'}
    $http({
    url: "www.infinityknow.com/do_fetchdata.php",
    method: "POST",
    params: data_valu
    })
	

Example 3 :display username authentication in angularjs using Post Method

		$http.post('https://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;
		});
				

Example 4 : Full source code : $http.post server request in AngularJS


    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('https://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 +
                    "<br /><hr />Value of status: " + status +
                    "<br /><hr />headers value : " + header +
                    "<br /><hr />config value : " + config;
            });
        };

    });


Angularjs demo

https://docs.angularjs.org/api/ng/service/$http

READ :  Create Laravel Pagination using Vuejs CRUD

Add a Comment

Your email address will not be published. Required fields are marked *