user500468
user500468

Reputation: 1221

Doing $http.get with AngularJS

Im trying to do a $http.get with angular:

var monster_info = angular.element(this).find("img").attr("title");
                        $http.get("lib/terrain.php", {monster_data: monster_info}).success(function(data) {
                            console.log(data);
                        });

Here is my terrain.php:

$data = file_get_contents("php://input");
    $objData = json_decode($data);
    echo $objData->monster_data;

The only returns an empty string when using GET. But if I change to $http.post, it works perfect. How can I make it work with $http.get?

Upvotes: 0

Views: 84

Answers (1)

Archana
Archana

Reputation: 387

Please try this,

var monster_info = angular.element(this).find("img").attr("title");

$http.get("lib/terrain.php", {

params: { monster_data:monster_info}}).success(function(data) {

console.log(data);  

});

Upvotes: 1

Related Questions