0
好吗更新按钮值,这里的情况:的jQuery活不上成功
<div>
<a href=".." id=".."></a> //similarly multiple links
</div>
当用户点击任何链接,它的id
是由一个AJAX请求GET
变量传递。一旦成功,另一个<div>
得到充满了一些其上写有一些值的按钮列表。当用户点击按钮时,他可以通过在警告框中输入新值来更改写在按钮上的值。这也是由AJAX请求完成的。但是,成功后,值会在数据库中更新,但已更改的值不会写回按钮。
$('#tags a').click(function(e){
e.preventDefault();
var send = $(this).attr('href');
$.ajax({
url:'getitemsfortag.php',
data:{tag:send},
type:'GET',
dataType:'html',
success:function(data){
$('#items').empty().append(data); //data contains list of buttons
},
error:function(xhr, status){
alert("Problem");
}
});
});
$("input[type='button']").live('click',function(){
var selected = $(this).attr("id");
var val = prompt("Enter new value",0);
$this = $(this);
$.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");
}
});
});
});
有关如何获取更改值写回按钮的任何建议?
@devmatt:罗.. – 2011-06-03 12:06:28
什么,当你这样做会发生什么? – devmatt 2011-06-03 12:10:07
@devmatt没有什么..只是像以前一样.. – 2011-06-03 12:12:17