Jquery Append

I want call an php funtion and return a value.

This value has to be appended to a div. I try a lot of things but nothing works. This is more far that i get:




echo CHtml::ajaxSubmitButton('add one more',

    CController::createUrl('cadTabelapreco/UpdateFilho'),

array('type'=>'POST',

      'data'=>array('item'=>'CadTabelaprecoi',

                    'i'=>$i,            

      'complete' => 'function(){

            $("#data").append($(this).html()); 

      }',         

));

I also try this:




array('type'=>'POST',

      'data'=>array('item'=>'CadTabelaprecoi',

                    'i'=>$i,

                    'form'=>$form),            

      'complete' => 'function(ret){

            $("#data").append().val(ret); 

      }',         

));



The thing is, if i debug it with firebug, i see the response and its right, but i cant append the value to the div. Anyone know how to do that?

As far as I know, you have to append an HTML node upon success, but I may be wrong. Also maybe adding ‘js:’ in front of function so that Yii parses it correctly…


'success' => 'js:function(data) {

    $("#data").append("<div></div>").html(data);

}'

Tnxs for reply bennouna, but didn’t work. It cleans my div, dont append =/

The below works for me:




'success'=>'js:function(data) {

	$("#data").append(data);

}'



If response is correct, try to append some string to #data div on success first, then when you know you can, try appending the data returned by your function.

Tnxs, i was using complete, not success, that was the problem!

Tnxs benona.