在电子邮件生成或通过 AJAX 发送后显示消息
showing message after email generation or sending through ajax
function registration_ajax(){
$this->load->library('form_validation');
$this->form_validation->set_rules('email','email','required|is_unique[register.email]');
if($this->form_validation->run() == FALSE){
$data = '{"status":"false","message":"Email already exists"}';
}
else
{
$email=$this->input->post('email');
$data= array(
'email'=>$email
);
$last_id = $this->model->registeration($data);
if ($last_id>0) {
$this->send_email($email);
$data = '{"status":"true","message":"Email Created successfully"}';
}
}
echo $data;
}
public function send_email($to='',$username="",$from='khadija@precisetech.com.pk')
///function send_mail()
{
$this->load->library('encrypt');
$toEmail = $this->encrypt->encode($to);
$toEmail = str_replace('/','forwardSlash',$toEmail);
$toEmail = str_replace('=','equalSign',$toEmail);
$toEmail = str_replace('+', 'plusSign', $toEmail);
$this->load->library('email');
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'sadasds';//pust mail.com.pk
$config['smtp_port'] = '25334';
$config['smtp_user'] = 'example';
$config['smtp_pass'] = 'example1';
$config['charset'] = 'utf-8';
$config['mailtype'] = 'html';
$config['validation'] = FALSE; // bool whether to validate email or not
$this->email->initialize($config);
$message = '<h1 align="center">Hellow</h1>';
$message = '<html><body style="color:#000; font-weight:normal; font-size:13/14px;"><p style="color:#000;">Hi!</p>';
$message .= '<table rules="all">';
$message .= "<p>Congratulations! You have almost completed your registration on Electronic Mall.<br><br>Click on link here to confirm your email address<br> <a href='"http://10.10.10.44/Freeclassified/index.php/controller/register_second/$toEmail'">10.10.10.44</a><br><br>Thank you for joining us and becoming part of world's largest local classified sites.In our website, you can enjoy simple ad posting, easy searching and endless local listing for products.We appreciate you for choosing us in online market place.<br> Wishing you alot of success on your classified journey.Get started now!<br><br></p>";
$message .= "<p>Regards,<br>The Electronic Mall Team</p>";
$message .= "</table>";
$message .= "</body></html>";
$this->email->from($from);
$this->email->to($to);
$this->email->subject('Confirmation Email');
$this->email->message($message);
if(!$this->email->send()){
echo $this->email->print_debugger();
die();
}else{
}
}
////ajx code
//////////////////
<script>
$(document).ready(function(){
$('#registration_form').on('submit',function(e){
var email = $('#email').val();
$.ajax({
url: "<?=base_url('controller/registration_ajax')?>",
// url: "<?=base_url('controller/register')?>",
type: "POST",
datatype: "JSON",
data: {email: email},
success: function(res){
var data = $.parseJSON(res);
var status = data.status;
var message = data.message;
if(status == 'true'){
/// $('#myModal').modal('hide');
$('#message_sent').html(message);
}
else{
$('#message').html(message);
}
}
});
e.preventDefault();
});
});
</script>
我希望在成功发送电子邮件后,应该显示此消息
$data = '{"status":"true","message":"Email Created successfully"}';
当我评论邮件发送功能时,它会显示成功的消息,我希望在发送电子邮件后显示该消息。
您是否尝试过从send_email函数返回值?
if(!$this->email->send()){
return 'success';
}else{
$this->session->set_flashdata('message', 'To complete registration, click the link in email we just send you at khadija@precisetech.com.pk');
redirect('controller/login_register','refresh');
die();
}
然后在您的 :
if ($last_id>0) {
$res = $this->send_email($email);
if($res === 'success'){
$data = '{"status":"true","message":"Email Created successfully"}';
}
}
相关文章:
- 如果下载不成功,如何显示消息
- 如何在 jquery 中的速率按钮下方显示消息状态
- 删除所有可拖动元素后如何显示消息
- php表单验证n在表单上显示消息3秒钟并淡出
- 单击“点赞”按钮时显示消息
- javascript初学者-无法在屏幕上显示消息框
- 在表单提交后显示消息的方法
- 遍历列表,并在jQuery为空时显示消息
- 在jquery幻灯片登录表单上显示消息
- 如果文本筛选器在ng重复中未返回结果,则显示消息
- 以javascript显示消息框
- 在angular 1中,我如何检测angular是否受支持,并在屏幕上显示消息's不受支持
- 浏览器全屏显示,按键时不显示消息
- 选取随机数组元素,将其移除,并在没有更多可用元素时显示消息
- 仅当浏览器不是Google Chrome时显示消息
- 如果所有李都被隐藏,则显示消息
- 在提交表单和显示消息之前,如何检查表单输入是否全是数字
- 如果使用 JavaScript 登录失败,如何在登录页面中显示消息
- j查询验证未显示消息
- 为什么不显示消息