Perino
Perino

Reputation: 628

Joomla redirect after ajax request fails

An ajax request calls a controller function within my MVC Component. And in this function there is a Joomla redirect at the end with

JFactory::getApplication()->redirect(JRoute::_($redirect_url, false));

The problem is, that the redirected page won't open! While debugging a session, I can see that the controller will initiate the redirect and the proper details will be sent to view.html.php. But the page, in this case it is a different view in tmpl, will not be open!

Is this because of the ajax call? Do I have to do something in the ajax success part?

Upvotes: 0

Views: 924

Answers (1)

Perino
Perino

Reputation: 628

Yes, now I do the url preparation in the controller and send back the url to ajax.

$redirect_url = "index.php?option=com_mycomponent&view=my_view&layout=different_layout"

Ajax will do the redirect with the given url. window.location = result.data;

From there iam struggeling with the SEF part of Joomla to get a SEF friendly URL.

Upvotes: 1

Related Questions