I have several buttons on one page. After clicking, I will track the button identifier, send the button value for the php backup code, which returns me the updated value by changing the database. I can return everything I need, except for this: setting the button value on successful execution! This is the code I'm using:
$(document).ready(function(){ $("input[type='button']").click(function(){ var selected = $(this).attr("id"); var val = prompt("Enter new value",0); $.ajax({ url:'updateCostItems.php', data:{toupdate:selected, updatewith:val}, type:'GET', dataType:'json', success:function(json){ $(this).val(json.update); }, error:function(xhr, status){ alert("Problem"); }, complete:function(xhr, status){ } }); }); });
source share