有什么方法可以放置一个触发器来在 CodeIgniter 的控制器函数中切换引导模式
Is there any way I can put a trigger to toggle Bootstrap modal inside a controller function in CodeIgniter?
我想创建一个模块,学生必须提供他/她的学生证、PIN 和电子邮件来验证他/她的帐户。如果用户输入了正确的 ID、PIN 和电子邮件,则必须显示设置他/她的密码的模式。
视图
<form method="post" action="<?php echo site_url('mycontroller/validateStud');?>" name="formvalidate">
<div class="form-group">
<input type="text" class="form-control" name="idnum" placeholder="ID Number"/>
<br>
<input type="email" class="form-control" name="mail" placeholder="Student Email"/>
<br>
<input type="password" class="form-control" name="pin" placeholder="Student PIN"/>
<br>
<button type="submit" class="btn btn-primary" style="width: 100%;" onclick="" name="submit2" value="<?php echo $this->uri->uri_string(); ?>" id="validated">Validate</button>
</div>
</form>
<div id="myModal" class="modal fade" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title">Modal Header</h4>
</div>
<div class="modal-body">
<p>Some text in the modal.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
</div>
</div>
控制器我的控制器.php
public function validateStud()
{
$submit=$this->input->post('submit2');
$studentId=$this->input->post('idnum');
$saispin=$this->input->post('pin');
$mail=$this->input->post('mail');
$res=$this->mymodel->checkValidation($studentId, $pin, $mail);
if (isset($_POST['submit2']) && $res) { //if the three inputs matched with a student record
//Open MyModal that will set account password
}
else if(isset($_POST['submit2']) && !$res)
{
//No record found
}
else
{
redirect('index', true);
}
}
我尝试过javascript,但我失败了。请开导我。任何帮助将不胜感激。:)
最好使用 ajax 将值发布到服务器,以便您可以在成功回调中触发模式打开。这样,如果失败,您还可以触发它以使用其他消息打开。它会更干净。
$.ajax({
url: '',
type: '',
data: {},
success: function(){},
error: function(){}
});
像这样的东西。查看 jQuery 文档以获取更多信息
相关文章:
- AngularJS执行指令模板中的控制器函数
- Angularjs:路由后如何调用控制器函数
- 为什么控制器函数没有执行 Angular Js 1.5.5
- 在 html5 视频结束时调用 AngularJS 控制器函数
- Angularjs指令调用控制器函数
- 从浏览器调用角度控制器函数
- 如何在angular js中从指令调用控制器函数
- AngularJS-如何在ng中继器中调用以项值为参数的控制器函数
- Angularjs将函数从控制器传递到指令(或从指令调用控制器函数)-带参数
- 如何使用ajax从javascript调用控制器函数
- 触发视图'的控制器函数
- 从AngularJS中的视图调用控制器函数
- 当使用Angular1+ES6时,控制器函数中未定义依赖注入,控制器是一个类
- 从指令角度调用控制器函数
- 从指令调用控制器函数(使用从指令传递的参数)
- 从 Karma 和 Jasmine 测试调用控制器函数
- 从指令调用角度控制器函数
- 有什么方法可以放置一个触发器来在 CodeIgniter 的控制器函数中切换引导模式
- 如何修复角度 js ng 控制器函数调用
- 我可以将变量控制器函数传递给指令中的函数链接吗?