js ajax submit data - PhucVM2019/frontEnd GitHub Wiki
//2020-03-26 10:35:38 PhucVM
(function () {
//load page
function loadpage() {
if ($("#numberstatus").val() == '1') {
$("#cancel").addClass("fpts-btn--gsmRengiter");
$("#rengiter").removeClass("fpts-btn--gsmRengiter");
} else if ($("#numberstatus").val() == '4' || $("#numberstatus").val() == '5') {
$("#cancel").removeClass("fpts-btn--gsmRengiter");
$("#rengiter").addClass("fpts-btn--gsmRengiter");
}
}
//2020-03-26 10:35:38 PhucVM
//đăng ký tham gia hội thảo
function rengiter() {
$("#rengiter").click(function () {
var purchaserightcode = $("#purchaserightcode").val();
var maCD = $("#maCD").val();
var status = "1";
var form_data = { "purchaserightcode": purchaserightcode, "maCD": maCD, "status": status };
var post_url = url;
var request_method = "post";
var form_data = form_data;
$.ajax({
url: post_url,
type: request_method,
data: JSON.stringify(form_data),
contentType: "application/json; charset=utf-8",
dataType: "json"
}).done(function (response) {
console.log("Đăng ký thành công");
$("#rengiter").addClass("fpts-btn--gsmRengiter");
$("#cancel").removeClass("fpts-btn--gsmRengiter");
}).fail(function () {
console.log("Đăng ký không thành công");
});
});
}
//2020-03-26 12:35:38 PhucVM
//Hủy đăng ký tham gia hội thảo
function cancel() {
$("#cancel").click(function () {
var purchaserightcode = $("#purchaserightcode").val();
var maCD = $("#maCD").val();
var status = "2";
var form_data = { "purchaserightcode": purchaserightcode, "maCD": maCD, "status": status };
var post_url = url;
var request_method = "post";
var form_data = form_data;
$.ajax({
url: post_url,
type: request_method,
data: JSON.stringify(form_data),
contentType: "application/json; charset=utf-8",
dataType: "json"
}).done(function (response) {
console.log("Hủy đăng ký thành công");
$("#rengiter").removeClass("fpts-btn--gsmRengiter");
$("#cancel").addClass("fpts-btn--gsmRengiter");
}).fail(function () {
console.log("Hủy đăng ký không thành công")
});
});
}
function main() {
loadpage();
rengiter();
cancel();
};
main();
})();