Pardeep Pardeep - 1 year ago 57
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...

Answer Source

Use text method to change the text of the button



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



Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download