ajax - How can i make full post-back request from angularJS to phalcon php
I have an angularJS + PHP application. What i would like to achieve is a "Full Post" request to Phalcon PHP controller.
Angular:
$http.post('/controller/sampleAction/', {params}).
success(function(data, status, headers, config) {
}).
error(function(data, status, headers, config) {
});
Phalcon PHP:
public function sampleAction()
{
ControllerBase::indexAction();
if ($this->request->isPost() == true) {
// Access POST data
$this->view->paramA = $this->request->getPost("paramA");
$this->view->paramB= $this->request->getPost("paramB");
}
}
I am getting to phalcon controller, setting my view params but the view is not rendered because its an AJAX request. How can i still use POST function and redirect/render the sampleAction view?
Answer
Solution:
Here are my findings and solution for my problem:
Apparently Phalcon does return the view.
The reason that the view was not rendered as a full post-back response is that Angular is a Single-Page JS framework, so if i want to use it i should build my app accordingly.
So, instead of requesting a full page from Phalcon i changed my architecture, so i will only get relevant Json data from Phalcon while rendering the view purely in angularJS using a directive.
Answer
Solution:
False. Unsless you have disabled view by yourself in case of ajax request. Check out your code, share us whats happening in
ControllerBase::indexAction()
and ininitialize()
if defined and something related to requests/view.