我需要一个想法,如何将所有这些功能结合在一起,它们只有很小的区别,有buyer1 buyer2 buyer3
什么想法吗?预先感谢
这会很有帮助,因为我有很多看起来相似的代码,而 js packer 没有多大帮助
function buyer1() {
var f = $("#buy_id").val();
var n = $("#buyer_id").val();
var z = $("#token_id").val();
var t = $("#buy_value").val();
$.ajax({
url: "ajax.php",
type: "post",
data: "action=buyer1&pet_id=" + f + "&my_id=" + n + "&token=" + z + "&buy_value=" + t + "",
dataType: "json",
success: function (e) {
token_id = e.token_id;
message = e.message;
value = e.value;
$("#buy_value").val(value);
$("#token_id").val(token_id);
$("#buyerdialog").fadeIn(300);
$("#buyerresult").html(message);
},
error: function () {}
})
}
function buyer2() {
var f = $("#buy_id").val();
var n = $("#buyer_id").val();
var z = $("#token_id").val();
var t = $("#buy_value").val();
$.ajax({
url: "ajax.php",
type: "post",
data: "action=buyer2&pet_id=" + f + "&my_id=" + n + "&token=" + z + "&buy_value=" + t + "",
dataType: "json",
success: function (e) {
token_id = e.token_id;
message = e.message;
value = e.value;
$("#buy_value").val(value);
$("#token_id").val(token_id);
$("#buyerdialog").fadeIn(300);
$("#buyerresult").html(message);
},
error: function () {}
})
}
function buyer3() {
var f = $("#buy_id").val();
var n = $("#buyer_id").val();
var z = $("#token_id").val();
var t = $("#buy_value").val();
$.ajax({
url: "ajax.php",
type: "post",
data: "action=buyer3&pet_id=" + f + "&my_id=" + n + "&token=" + z + "&buy_value=" + t + "",
dataType: "json",
success: function (e) {
token_id = e.token_id;
message = e.message;
value = e.value;
$("#buy_value").val(value);
$("#token_id").val(token_id);
$("#buyerdialog").fadeIn(300);
$("#buyerresult").html(message);
},
error: function () {}
})
}