이것은 내 첫 번째 질문으로, 내 영어 실례입니다.http.get with params send word query
저는 각도로 작업하고 있으며 http.post를 모두 사용하고 있습니다 (get 및 post 정보). 그리고 이것이 어떻게 잘못된지, 나는 데이터베이스에서 레코드를 요청하기 위해 http.get을 사용하기 시작할 것입니다.
내가 이것을 사용하고이를 보낼 수 있기 때문에,
empresa.php?id=-1&action=get
그러나 작동하지를 :
$http.get("empresa.php",{params:{id:-1,action:"get"}})
내가 이런 식으로 뭔가를받을 것으로 예상
empresa.php?query=%7B%22id%22:-1,%22action%22:%22get%22%7D
당신이 나를 도울 수 ?
쿼리이 아닙니다. POST에 대한
app.factory("Data", ['$http',
function($http,) { // This service connects to our REST API
var serviceBase = 'service/';
var obj = {};
obj.get = function(q,p) {
console.log(p);
return $http.get(serviceBase + q + ".php",{params:p}).then(function (results) {
return results.data;
});
};
obj.post = function(q, object) {
return $http.post(serviceBase + q + ".php", object).then(function(results) {
return results.data;
});
};
obj.put = function(q, object) {
return $http.put(serviceBase + q + ".php", object).then(function(results) {
return results.data;
});
};
obj.delete = function(q) {
return $http.delete(serviceBase + q + ".php").then(function(results) {
return results.data;
});
};
return obj;
}
]);
잘 작동하지만, GET 작동하지 않습니다 :(
: 나는 EDITION 테 공장이있다 AngularJS와 1.5.8
을 사용하고
새 편집
Here you can see how is that I have the code, how use and the response
편집 - 말
을 확정, 나는 JSON 객체를 직렬화하고 도움을 모든 empresa.php에 전화에 직접감사를 넣어 $ httpParamSerializer를 사용하여 해결! !! !!
그렇다면 문자를 백분율 인코딩으로 변환하지 않고 get 쿼리를 보내는 방법을 알고 싶습니까? – ncke
예, 그렇게하고 싶습니다. @ncke – DanielB