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

[eluser]MungeGerard[/eluser]
Quote:I hope you see how that works. This is untested since I did it in the browser, if you give it a try and something doesn't work correctly let me know and I'll help debug it.

Thanks for all the help, but the exit method didn't work. I looked at JSON and it seems promising, I found an example and did exactly the same.

Javascript
Code:
var sUrl = ($("input#url").val() + "index.php/contact/send");
var sName = $("input#name").val();

$.post(sUrl, { 'item' : sName },
    function(data){
    alert(data.result);
}, "json");

Controller
Code:
function send() {
    return($result);
    $item = '1234';      //trim($this->input->post('item'));
    $array = array('result' => $item);
    echo json_encode($array);
}

Still no data gets returned to the javascript. When I call the contoller/function directly I get the following output:
Code:
{"result":"1234"}

So do you have any ideas?


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