Mohamed A. Shebl
Mohamed A. Shebl

Reputation: 384

Why Sending Params in Post Works like GET

I am Trying to make an http post request to .php file at the server all what i do is making the request like this

$http({
            url: 'http://localhost/sebha/login.php',
            method: 'POST',
            params: paramss
        }).success(function(response) {
            if (response.pk) {
                $state.go('tab.home');
            } else {
                console.log('error');
            }
        });

but when i trying to receive these parameters at the backend, i could not get them from the $_POST array so when i checked the network in chrome to check the request i found that the Request URL is shown like that however this is a POST request not a get

http://localhost/sebha/login.php?password=admin&username=admin

i just want to know why the parameters are sent in the URL like exactly a GET request and how i get it work.

Upvotes: 0

Views: 55

Answers (1)

tymeJV
tymeJV

Reputation: 104775

params is for GET requests and will encode the URL - use the data paramter:

 $http({
        url: 'http://localhost/sebha/login.php',
        method: 'POST',
        data: paramss
    }).success(function(response) {
        if (response.pk) {
            $state.go('tab.home');
        } else {
            console.log('error');
        }
    });

Upvotes: 4

Related Questions