gpt4 book ai didi

php - 模态不在 php (CodeIgniter) 中使用 javascript 加载

转载 作者:可可西里 更新时间:2023-11-01 09:00:30 26 4
gpt4 key购买 nike

我想在成功提交表单时打开模型,但是尽管表单正在提交,但模态没有弹出。

public function insert($data) {
// Inserting into your table
// Calling model
$done = $this->db->insert('sign_up', $data);

if($done) {
echo "<script>$('#thankyouModal').modal('show')</script>";
echo '<div class="modal fade" id="thankyouModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Thank you for pre-registering!</h4>
</div>
<div class="modal-body">
<p>Thanks for getting in touch!</p>
</div>
</div>
</div>
</div>';
}
}

我正在尝试使用

在 Controller 中打开模型
   $data = array(
'first_name' => $fname,
'last_name' => $lname,
'email' => $email,
'password' => $password
);
$this->load->model('modal');
$this->modal->insert($data);

最佳答案

试试下面的代码;这会起作用

public function insert($data) {
// Inserting into your table
// Calling model
$done = $this->db->insert('sign_up', $data);

// You can do something else here
if($done) {
?>
<script>$(document).ready(function(){$('#thankyouModal').modal('show')});</script>
<div class="modal fade" id="thankyouModal" tabindex="-1" role="dialog">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
<h4 class="modal-title" id="myModalLabel">Thank you for pre-registering!</h4>
</div>
<div class="modal-body">
<p>Thanks for getting in touch!</p>
</div>
</div>
</div>
</div>
<?php
}
}

关于php - 模态不在 php (CodeIgniter) 中使用 javascript 加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44692125/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com