0

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?

1 Answer 1

1

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);  

});

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.