单击接受后显示警报消息和重定向 [英] Display alert message and redirect after click on accept
问题描述
好吧,我有一个页面,其中包含报告的链接。每当有人点击一个报表,他们可以下载excel文件。然而,有时没有字段来报告;在这种情况下,我想显示一个警报消息,他们单击接受后,他们被重定向到主面板。当他们点击报告时,他们去一个控制器,使用开关
获取数据。如果没有数据,模型返回 FALSE
;所以在控制器的最后,我检查:
Well, I have a page with links to reports. Whenever somebody clicks on one report, they can download the excel file. However, sometimes there are no fields to make a report; in that case, I want to display an alert message and after they click on "accept", they get redirected to the main panel. When they click on the report, they go to a controller that uses a switch
to get the data. If there's no data, the model returns FALSE
; so at the end of the controller, I check:
if ($result_array != FALSE)
to_excel($result_array->result_array(), $xls,$campos);
else {
echo "<script>alert('There are no fields to generate a report');</script>";
redirect('admin/ahm/panel');
}
如果我摆脱了 redirect ahm / panel');
然后警报工作,但它将用户移动到应该生成excel文件的页面。但是,如果我使用重定向,控制器会将用户移动到主面板,而不显示警报。
If I get rid of redirect('admin/ahm/panel');
then the alert works, but it moves the user to the page that was supposed to generate the excel file. But if I use the redirect, the controller moves the user to the main panel without showing the alert.
任何帮助都很感激。
提前感谢。
推荐答案
echo "<script>
alert('There are no fields to generate a report');
window.location.href='admin/ahm/panel';
</script>";
并除去下面的 redirect
你混淆了两个不同的世界。
You were mixing up two different worlds.
这篇关于单击接受后显示警报消息和重定向的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!