Welcome Guest, Not a member yet? Register   Sign In
posting data via jquery json (solved)
#1

[eluser]gazza7364[/eluser]
Hi

I've been following a tutorial about posting data from a dropdown using jquery and json.
I have tested to see if the data is being passed using the alert in jquery, before being posted, which is coming back with the correct choice from the dropdown list. But when I post the data I get no result.

This is jquery code
Code:
$(document).ready(function() {
            
$("#sendit").click(function() {

var item = $("#input option:selected").val();
        
          //alert(item);

$.post("db/test2", { item:item },


   function(data){
  
        alert(data.result);
    }, "json");  

    });
        
})

Here is the code
Code:
unction test2()
    {
$item = trim($this->input->post('item'));
$array = array('result' => $item);
echo json_encode($array);


}


I have left the alert in jquery to test the result.

Thanks in advance for any pointers.




Theme © iAndrew 2016 - Forum software by © MyBB