-2
假設我有一個我可以調用AJAX使用元素ID,而不是在任何情況下
if(ond1satisfied){
<div id="checkA">
</div>}
if(cond2satisfied){
<div id="checkB">
</div>}
我可以調用AJAX如
$.ajax({
url: 'example.php',
type: 'GET',
success: function(data) {
//called when successful
$('#ajaxphp-results').html(data);
},
error: function(e) {
//called when there is an error
//console.log(e.message);
}
});
像
$("#checkA").ajax({
url: 'exampleA.php',
type: 'GET',
success: function(data) {
//called when successful
$('#ajaxphp-results').html(data);
},
error: function(e) {
//called when there is an error
//console.log(e.message);
}
});
$("#checkB").ajax({
url: 'exampleB.php',
type: 'GET',
success: function(data) {
//called when successful
$('#ajaxphp-results').html(data);
},
error: function(e) {
//called when there is an error
//console.log(e.message);
}
});
即我可以直接使用id來調用ajax,而無需任何事件
根據用戶類型(A,B)有一個登錄表單,將通過ajax顯示相應的表單(A,B)。這裏如果條件satiafied阿賈克斯呈現形式和AJAX渲染formB
能不能做到
這可能嗎? 如果不是我如何實現呢?
你能告訴我們 –
你的意思是你的情況可以手動觸發回調函數? – MjrKusanagi
@janinahane更新我的問題 – user3419342