Welcome Guest, Not a member yet? Register   Sign In
Return values from CI controllers to Javacript (jQuery)
#1

[eluser]MungeGerard[/eluser]
Hi all,

I'm building my 1st website with CI and I must say, it's really great!

At this point I'm programming an Ajax(jQuery) / Controller combination to submit my forms. But I just can't figure out how to return a value from the codeigniter controller to the javascript function that calls the controller.

Javascript function
Code:
$.ajax({
    type: "POST",
    url: sUrl,
    data: sData,
    success: function(response) {
        alert(response);
    }
});

CI controller
Code:
function send() {
    if($this->session->userdata('session_id')==$_POST['sVerification']){
        if($this->email->send()){
            $result = 'send';
        }
        else {
            $result = 'error';
        }
    }
    else {
        $result = 'sessionerror';
    }
    print_r($result);
    return($result);
}

I summarized the scripts, I only included the lines that matter Smile

Everything works fine, only no data gets returned to the javascript.

Hope you guys can help me out here,

Gerard


Messages In This Thread
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 10:26 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 10:38 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 10:40 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 12:43 PM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 12:53 PM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 12:56 PM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 01:21 PM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 03:15 PM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 02-28-2010, 07:03 PM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 03-01-2010, 03:33 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 03-01-2010, 03:37 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 03-01-2010, 08:22 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 04-01-2010, 07:54 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 04-01-2010, 08:09 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 04-01-2010, 08:13 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 04-16-2010, 07:51 AM
Return values from CI controllers to Javacript (jQuery) - by El Forum - 04-16-2010, 08:30 AM



Theme © iAndrew 2016 - Forum software by © MyBB