从javascript加载codeigniter控制器和方法
我将jQueryAjax与$.confirm结合使用,我需要弄清楚如何加载codeigniter控制器/方法以响应$.confirm。代码如下:从javascript加载codeigniter控制器和方法,javascript,jquery,ajax,codeigniter,Javascript,Jquery,Ajax,Codeigniter,我将jQueryAjax与$.confirm结合使用,我需要弄清楚如何加载codeigniter控制器/方法以响应$.confirm。代码如下: $.ajax({ url: sURL + "utility/ajaxFind_In_tblClients", type: "POST", data: {ClientNum: ClientNum}, dataType: 'json', success: function(json) { $.confi
$.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响应“Yes”后如何加载codeigniter控制器。有什么想法吗?谢谢。创建一个函数:
function send_email(email){
$.ajax({
type:'post',
url: '/email_controller/send_email',
data: 'email='+email,
error: function(){},
success: function(){}
}
}
并在YES函数中调用它{
$.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.
}
}
url:“控制器名称/功能名称”,
类型:“POST”,
数据:“客户端=”+客户端,
数据类型:“json”,
成功:函数(){
//为了成功,做你想做的一切。这取决于你的控制者。
}
}
我也会将整个URL放入。您可以添加另一个ajax调用。ajax是调用服务器端代码的唯一方法。另一种方法是表单提交或链接单击,但您不想这样做。