• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to send array in jquery to controller?

#1
[eluser]shinokada[/eluser]
I am learning ajax with jquery and CI.

I am not doing right with the following jquery code and a controll function.

I think I am not doing right with this line.

$.getJSON(
'phpjquerybook/inline_editing_do',
{'id':id,'field_name':field_name,'value':this.value},


or
function inline_editing_do($id=null){
$id=(int)$id['id'];
$field_name = addslashes($id['field_name']);
$value= addslashes($id['value']);

I think I am not sending/receiving array correctly.

Any help will be appreciated it.

Thanks.


Jquery code.

Code:
...
...
function inline_editing_save(){
    var id,field_name,p;
    p=this[removed];
    if(p.originalHTML==this.value)
        return inline_editing_restore(p);
    field_name=p.className;
    id=$(this).closest('tr')[0].id.replace(/.*_/,'');
    $.getJSON(
        'phpjquerybook/inline_editing_do',
        {'id':id,'field_name':field_name,'value':this.value},
        inline_editing_callback
    );
}
...
...

Controller

Code:
function inline_editing_do($id=null){
        
        // $id=(int)@$_REQUEST['id'];
        // $field_name=addslashes(@$_REQUEST['field_name']);
        // $value=addslashes(@$_REQUEST['value']);
        $id=(int)$id['id'];
        $field_name = addslashes($id['field_name']);
        $value= addslashes($id['value']);
        echo ( !($id%2) )?
            "{'id':$id,'field_name':'$field_name','success':1,'value':'$value'}":
            "{'id':$id,'field_name':'$field_name','success':0,'error':'Could not save data'}";
        
    }


Messages In This Thread
How to send array in jquery to controller? - by El Forum - 01-09-2010, 01:04 AM
How to send array in jquery to controller? - by El Forum - 01-09-2010, 05:14 AM
How to send array in jquery to controller? - by El Forum - 01-09-2010, 06:35 AM
How to send array in jquery to controller? - by El Forum - 01-09-2010, 06:43 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.