我正在使用jquery ajax和$ .confirm,我需要弄清楚如何加载一个codeigniter控制器/方法来响应$ .confirm。这是代码:
$.ajax({
url: sURL + "utility/ajaxFind_In_tblClients",
type: "POST",
data: {ClientNum: ClientNum},
dataType: 'json',
success: function(json) {
$.confirm("The email address registered to this account is:\n\n"
+json.ClientEmail+
"\n\nSend password recovery information to this email address?"+
"\n\nIf you need assistance, please call 888-526-9999.",
//YES
function(){
//need to load a codeigniter controller here
$.msg("Password recovery information has been sent.\nPlease check your inbox",
{header:'Password Sent', live:10000});
$('#ajaxShield').hide();
},
//NO
function(){
$.msg("Password recovery information has NOT been sent.",
{header:'Password Not Sent', live:10000});
$('#ajaxShield').hide();
}
) //end of confirm
}, //end of success: function(json), could be YES or NO inside
error:function (xhr, ajaxOptions, thrownError){ alert('Problem with utility/ajaxFind_In_tblClients Status code:'+xhr.status+', Error:'+thrownError);}
});
看起来我需要帮助才能在第14行做什么。我不知道在用户对$ .confirm回答“是”之后如何加载codeigniter控制器。有任何想法吗?感谢。
答案 0 :(得分:1)
创建一个函数:
function send_email(email){
$.ajax({
type:'post',
url: '/email_controller/send_email',
data: 'email='+email,
error: function(){},
success: function(){}
}
}
并在YES函数中调用它
答案 1 :(得分:0)
$.ajax{
url: "<?php echo base_url()?>controller_name/function_name",
type: "POST",
data: "client="+client,
dataType: "json",
success: function(){
//do everything you want for success. it depends on your controller.
}
}