Skip to main content

When deleting an answer, blank page with JSON?

955 Views
0 Replies
1 min read
Hi Guys.
When i delete an answer or unpublish an answer, it completes the task successfully but redirects me to a blank page with a JSON output on it, rather than the previous page with an alert...


{"error":"Item is deleted."}



function deleteAnswer(){
$user = &JFactory::getUser();
$answer_id = JRequest::getVar('id',0,'','INT');
if(!CAuthorization::authorise('answers.manage')){
echo json_encode(array('error'=>JText::_('NOT_AUTHORIZED')));
}else{
if(!$answer_id){
echo json_encode(array('error'=>JText::_('MSG_DELETE_FAIL')));
}else{
$model = &$this->getModel('answers');
if($model->deleteAnswer($answer_id)){
$this->setRedirect(JRoute::_('index.php?option='.APP_NAME.'&view=answers'.$itemid, false), JText::_('MSG_DELETE_SUCCESS'));
echo json_encode(array('data'=>JText::_('MSG_DELETE_SUCCESS')));
}else{
echo json_encode(array('error'=>JText::_('MSG_DELETE_FAIL')));
}
}
}
jexit();
}


Any ideas what is causing this?

0 Replies

No Replies Yet

Topic Author

A

adamck

@adamck

Topic Stats

Created Thursday, 26 April 2012 12:31
Last Updated Thursday, 26 April 2012 12:31
Replies 0
Views 955
Likes 0

Share This Topic