[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'}";
}