这是我的代码。 我想传递ID以在控制器中用于删除
$config['email_smtp'] = TRUE;
$config['email_from'] = 'mail.example.com';
$config['email_from_name'] = 'mail';
$config['admin_email'] = 'mail.example.com';
$config['mailtype'] = "html";
$config['crlf'] = "\r\n";
$config['newline'] = "\r\n";
$config['wordwrap'] = FALSE;
$config['charset'] = "utf-8";
/**
* SMTP Settings
*/
if ($config['email_smtp'] === TRUE) {
$config['protocol'] = "smtp";
$config['smtp_host'] = 'support@example.com';
$config['smtp_port'] = '465';
$config['smtp_timeout'] = '5';
$config['smtp_user'] = 'mail.example.com';
$config['smtp_pass'] = 'password';
}
这是将<button onclick="Delete(<?php echo $article->id; ?>)">Delete</button>
传递到控制器的功能
id
我想要此功能中的<script type="text/javascript">
function Delete(id)
{
var conf=confirm('Are you want to delete');
if (conf)
{
$.ajax({
url:'admin/delet_data',
type:"post",
data:{dlt_id:id},
});
}
}
</script>
id
答案 0 :(得分:0)
将ID与网址连接
js
url:'admin/delet_data'+id,
然后在控制器中使用像这样的功能
控制器
public function delet_data($id)
{
echo $id;
}