這是我的代碼我不想重復我的 ajax 我該如何優化它?然后有更短的代碼?所以我在這里只給你看一個例子:
function for() {
if (forceexs) {
if (login == "inte") {
$.ajax({
url: "index_content.php?mode=ppanel=forgotten&force_mssante=0",
success: function (html) {
$(".panel-body").html(i18n.tr(html));
$("#rpps").focus();
},
});
} else if (login == "ex") {
$.ajax({
url: "index.php?mode=nel=forgorce_mssante=1",
success: function (html) {
$(".panel-body").html(i18n.tr(html));
$("#rpps").focus();
},
});
} else {
$.ajax({
url: "index.php?mode=phel=internal_or_external",
success: function (html) {
$(".panel-body").html(i18n.tr(html));
$("#rpps").focus();
},
});
}
} else {
$.ajax({
url: "index.php?mode=pel=forgotten",
success: function (html) {
$(".panel-body").html(i18n.tr(html));
$("#rpps").focus();
},
});
}
}
這是最短的一個更容易理解
uj5u.com熱心網友回復:
function ajaxRequest(GETQuery) {
$.ajax({
url:'index_content?' GETQuery,
success: function(html) {
$(".panel-body").html(i18n.tr(html));
$("#rpps").focus();}
})
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/464962.html
標籤:javascript 阿贾克斯
