Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I'm new in Angular I want to get a SQL request from php script to angular, but I see only a big bulleted list and I dont know what is the problem.

My html code:

.
.
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.0.8/angular.js">
</script>
<script src="../js/proc_list.js"></script>
.
.
.
<div align="center" id="prod_list" ng-controller="proc_list">

<ul>
    <li ng-repeat="processor in proc">
    {{processor.manufacturer}}
    <p>{{processor.description}}</p>
    {{processor.price}}
    </li>
</ul>   

</div>

Controller code:

function proc_list($scope, $http){
$http.post('../phps/get_proc_list.php').success(function(data){
        $scope.proc = data;
    });
}

PHP code:

$received_data = file_get_contents("php://input");

$objData = json_decode($received_data);

require_once('login.php');
.
.
//Connect to database and send query
.
.
 $data_requested = json_encode($data);

echo $data_requested;

I tried to do similar like this link:http://www.cleverweb.nl/javascript/a-simple-search-with-angularjs-and-php/

but its still not working. Anybody has any idea? Thank you

share|improve this question
 
Start checking if the data is correctly post to the php script. Then check if the php script generate some valid response and so on. Only with snippets its hard to say which component of your application cause the problem. It is correct that you dont post any data to the server? What the sense here, use GET! –  tschiela Sep 12 at 13:55
add comment

2 Answers

The correct syntax of $http.post is $http.post('/someUrl', data).success(successCallback);

Read more about in the AngularJS docs: http://docs.angularjs.org/api/ng.$http#post

share|improve this answer
 
Originally it was $http.get request I tried this one as well, but yeah I know this is not valid format, but actually I replaced back to get, but still doesnt working. –  Zsoca Sep 12 at 14:01
 
generate the php script a valid response? –  tschiela Sep 12 at 14:03
 
Yeah it1s look like ok: webstore.mauritiusbeachhouses.com/phps/get_proc_list.php –  Zsoca Sep 12 at 15:06
add comment

Ok it's working now in this case not need to encode to json the $data, just simple send it back

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.