0

我将 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 控制器。有任何想法吗?谢谢。

4

2 回答 2

1

创建一个函数:

function send_email(email){
    $.ajax({
        type:'post',
        url: '/email_controller/send_email',
        data: 'email='+email,
        error: function(){},
        success: function(){}
    }
}

并在您的 YES 函数中调用它

于 2012-11-16T19:13:48.673 回答
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.
    }
}
于 2012-11-17T04:16:07.387 回答