In the form I have several 'buttons'. These
are not really buttons, they are images with href and onlick function,
which are initialising the ajax call. Submit buttons or Function would be prefered,
but not possible, because I need to transfer one value (productnr). And
each 'button' has its own product nr. So form submission can not be
done, instead I make a jquery ajax call to address the controller
function. But finally I need the redirect, which will normal be done, by
the last statement in the controller function
->redirect(JRoute::_....)
My ajax script:
jQuery(document).ready( function() {
jQuery(".productorder").click(function (SetOrder) { var order =
jQuery(this).find("#productnr").attr("value"); var formdata = new
FormData(); formdata.append("productnr", order); jQuery.ajax({
type: "POST", dataType: "json", data: formdata, processData:
false, contentType: false, url:
"index.php?option=com_component&task=controller.function",
success:function(result) { } }); }); });
In the success part I can do window.location = result.data but the url wich came from the controller is not correct.
The controller part for this is
$redirect_url = "index.php?option=com_mycomponent&view=my_view&layout=different_layout";
// JFactory::getApplication()->redirect(JRoute::_($redirect_url, false)); => this seems not really work i with the ajax call
echo new JResponseJson($redirect_url);
Maybe Iam on a wrong way and a different solution would be better?! In my view i need several buttons which are displayed with an image and should transfer a value (productnr) to the controller function. After submitting the form, I need to go to a different form.
Am Mittwoch, 2. Juli 2014 14:57:24 UTC+2 schrieb Sir Perino: