We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

redirecting in ajax

hi, I'am developing my web application that use ajax in some pages, but when I want to dispatch or redirect to other action in controller.. it's not working.... and the new page is replaced with ajax result div in my page.... is test the orders like disable view, render and dispacher, view pick,.... but they not solve my problem. Also I know how to solve this with jquery result by redirecting with windows.location but I want to redirect my page in controller... please help.... thanks



33.8k
edited Aug '14

I don't think you can do that using AJAX (as far I know). Whatever, you can try (if you have) putting a onsubmit event in your form page that calls an AJAX function you created. When you return a true in that onsubmit (cause of AJAX working correctly in some way), the form will do the action (that's it, the controller/action). Try with that if you have data you send to the server.

Hi, it's not possible to make ah http redirect or dispatching through an ajax request, but you can trigger the ajax success response and set a window.location. Read here: https://forum.jquery.com/topic/ajax-redirect-on-success-how-to-differentiate-response