embeding jquery code/executing jquery code which come from php
is there any way to writeIN a jquery code. i.e we write the echo 'some text'; in php.
in other words is there any alternative of echo/print in jquery.
actually i want to do is; i have an $.ajax function the body is below:
$.ajax({
type: "POST",
url: "<?=base_url()?>users/get_user",
data: "UserID="+userID,
success: function(html){
//alert(html);
//$(this).append(html);
$( "#create-dialog-form" ).dialog( "open" );
//alert(html);
//$("#users tbody").remove();
//location.reload();
//$( "#users tbody" ).html(html);
//$(".delete-user").button();
},
error: function(){
alert('Error while deleting');
},
cache:false
});
and the php file code is here..:
function get_user()
{
$UserID=$this->input->post('UserID');
$sql = 'select * from gpema_users where user_id='.$UserID;
$table_resultset = $this->commonModel->query($sql);
foreach ($table_resultset->result() as $row)
{
echo '$("#user_first_name").val("'.$row->user_first_name.'");';
echo '$("#user_last_name").val("'.$row->user_last_name.'");';
}
}
when the ajax request come back the [ success: function(html) ] the "html" has this one.
$("#user_first_name").val("Khalid''");
$("#user_last_name").val("Hussain'");
so what i want to do is to execute the following jquery code after/in ajax success function. plz help me on this
regards, khalid