Welcome Guest, Not a member yet? Register   Sign In
How to get the jSON data value and pass it to a Conroller?
#2

[eluser]stefenw[/eluser]
Quote:Deprecation Notice: The jqXHR.success(), jqXHR.error(), and jqXHR.complete() callbacks are deprecated as of jQuery 1.8. To prepare your code for their eventual removal, use jqXHR.done(), jqXHR.fail(), and jqXHR.always() instead.

i use this

returning json from controller
Code:
$x = $this->input->post('x');
echo json_encode(array("datacallback" => array("1" => $x)));

if result as row
Code:
$.ajax({
                        type: "POST",
                        url: //url target,
                        data: {x  : "abc"},//to add more ada
                        dataType: "json"
                    }).done(function(data){
var x = data.datacallback.1;
}

x will contain abc

if you need to loop trough returned json use this

Code:
$.each(data.datacallback, function(k, item) {
                    alert (item.arraykeyname)
                });


Messages In This Thread
How to get the jSON data value and pass it to a Conroller? - by El Forum - 10-31-2013, 01:46 AM



Theme © iAndrew 2016 - Forum software by © MyBB