Hi I'm developing custom component in Joomla. After successful save, my controllers set's 303 redirect with custom message. But with the AJAX interface in middle, my page does not seems to get redirected to that page. It stays on same page.
How do I handle 303 status code and force my page to redirect on page that is being set by controller?
Here is my js code:
$('#submit').click(function(e){
$('.requestForm').ajaxSubmit({
url: 'index.php?option=com_helpdesk&task=request.save',
type: 'POST',
beforeSubmit: function () {
$.blockUI({css: {
border: 'none',
padding: '15px',
backgroundColor: '#000',
'-webkit-border-radius': '10px',
'-moz-border-radius': '10px',
opacity: .5,
color: '#fff'
}});
},
success: function(result, status, xhr) {
var response = $.parseJSON(result);
if (!response['success'])
{
var html = '<div class="alert alert-warning alert-dismissible" role="alert">';
html += '<button type="button" class="close" data-dismiss="alert" aria-label="Close"><span aria-hidden="true">×</span></button>';
html += '<p><strong>Warning!</strong></p>';
$.each(response['messages']['error'], function (index, value) {
html += '<p>' + value + '</p>';
});
html += '</div>';
$('#system-message-container').html(html);
}
else
{
//Here my page get's 303 redirect which needs to be handle.
}
},
statusCode: {
// I tried this but this is not working
303: function() {
$.unblockUI();
alert('hurray');
}
},
complete: function () {
$.unblockUI();
}
});
e.preventDefault();
});