0

I am using jquery ajax in conjunction with $.confirm and I need to figure out how I can load a codeigniter controller/method in response to the $.confirm. Here is the code:

$.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);} 
});

Looks like I need help for what to do at line 14. I don't know how to load the codeigniter controller after the user responds "Yes" to the $.confirm. Any ideas? Thanks.

1
  • You can add another ajax call .Ajax is the only way to call the server side code.Another is form submit or link click but you don't wanna do that. Commented Nov 16, 2012 at 20:25

2 Answers 2

1

Create a function:

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

and call it in your YES function

Sign up to request clarification or add additional context in comments.

1 Comment

I would also put the entire URL in.
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.
    }
}

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.