I am trying to get data from a php script to my angular app. I am using this code to get the data. However it fails and then gives me no information why.
var req = {
method: 'GET',
url: 'http://www.hott-source.com/hangman/getMemory.php',
data: { }
}
$http(req).then(function(response){
alert("WINNER");
$scope.knownWords = response.data;
}, function(response){
alert(response.data);
});
The PHP script returns
[
["A","I"],
["BE","BY","DO","GO","IN","ME","MY"],
["CAT","COW","DOG","GOD","HIT","MAT","PAT","PIG","RUN","YOU"],
["BAND","BIRD","CART","CHIP","DOVE","JUMP","LOVE","READ"],
["CHIRP","HAPPY","HORSE"],
["CHURCH","HANSON","HITTER","PEOPLE","PRIEST","STRIKE","THOMAS"],
["BELINDA","BUILDER","SHOOTER"],
["CLAPPING","ELEPHANT"],
["COLLECTION"]
]
which I have verified as json. In the php file I set the header Content-Type to json just before I send it
header('Content-Type: application/json');
echo json_encode($newArray);
response.data alerts as null
How do I get the data from the php script into my $scope.knownWords