function vote(id)
{
	$.ajax({
		type: "GET",
		url: "ajax.php?action=vote&id=" + id,
		dataType: "json",
		cache: false,
		success: function(msg){
			//console.log(msg);
			if (msg.errno == 0)
			{
				$("#span_votes_" + id).html(msg.val);
				alert("投票成功，感谢您的参与。");
			}
			else
			{
				alert(msg.errmsg);
			}
		},
		error: function(msg){
			alert( "请求服务器失败");
		
		}
	}); 
}


function wanttobuy(id)
{
	$.ajax({
		type: "GET",
		url: "ajax.php?action=buy&id=" + id,
		dataType: "json",
		cache: false,
		success: function(msg){
			//console.log(msg);
			if (msg.errno == 0)
			{
				alert("感谢您的支持");
			}
			else
			{
				alert(msg.errmsg);
			}
		},
		error: function(msg){
			alert( "请求服务器失败");
		
		}
	}); 
}


function del(id)
{
	if (!confirm("您真的要删除吗？")) return false;

	$.ajax({
		type: "GET",
		url: "ajax.php?action=del&id=" + id,
		dataType: "json",
		cache: false,
		success: function(msg){
			window.location.reload();
		},
		error: function(msg){
			alert( "请求服务器失败");
		
		}
	}); 
}