Pardeep Pardeep - 6 months ago 16
Ajax Question

Change html button content on success

I just want to toggle html button content(activate or deactivate) on click of if button content is activate it changes this to deactivate....but not vice-versa... please have look on ajax code:

<button type="button" class="btn btn-success btn-sm" id="<?php echo $row->id; ?>" onclick="savestatus<?php echo $row->id; ?>(<?php echo $row->id; ?>)">Activate</button>

and my script is

function savestatus<?php echo $row->id; ?>(row_id){
type: "POST",
url: "<?php echo base_url().'home/activate_buyer/'. $row->id; ?>",
success:function( data )


please help...


Use text method to change the text of the button



i want if text is activate then onclick it becomes deactivate and vice-versa