現在、jquery の ajax 呼び出しに問題があります。私がやろうとしているのは、いくつかの div を空にし、コンテナーを非表示にしてから、要求された Ajax コードを呼び出して div をもう一度入力して表示することです。ただし、私のコードはリクエストを呼び出しており、ajaxリクエストの処理中にそれを非表示にして、divを空にしています...
カスタム コールバックを使用したサンプル コード (動作しない):
// This is defined within an element and is retrieving properly as well
cleanInfo(getCharacter($this.attr('id')));
function cleanInfo(callback){
// hide the container first, then empty and callback to ajax function
$('.sel_information_container').hide('slide', {direction: 'down'}, 'fast',function(){
$('.sel_info_top').html('');
$('.sel_info_description').html('');
$('.skill_tree').html('');
callback;
// OR
}, callback);
}
function getCharacter(id){
if(!id){
id = 0;
}
$.ajax({
// path is defined in core file this works right as it's retrieving the data properly... and everything is
// and everything is right in php...
url : _path + "/core/ajax.php",
type : 'POST',
data : { f: 'getCharacter', i: id },
dataType : 'json',
success : function(data) {
// if data error is sent back process it ...
if(data.error){
$('body').html(data.error);
}else{
// if no error populate and show the container
$('.sel_info_top').html(data.info);
$('.sel_info_description').html(data.desc);
$('.skill_tree').html(data.skills);
$('.sel_information_container').show('slide', {direction: 'down'}, 'slow');
}
}
});
}
ajaxSend/beforeSend/ajaxStart/always を使用したサンプル コード (動作しない):
// This is defined within an element and is retrieving properly as well
getCharacter($this.attr('id'));
// without callback and utilizing variable request...
function cleanInfo(){
$('.sel_information_container').hide('slide', {direction: 'down'}, 'fast',function(){
$('.sel_info_top').html('');
$('.sel_info_description').html('');
$('.skill_tree').html('');
});
}
function getCharacter(id){
if(!id){
id = 0;
}
// Instead of attaching the results to the var, I have also ran beforeSend: cleanInfo() which
// does the exact same thing as the above...
var request = $.ajax({
// path is defined in core file this works right as it's retrieving the data properly... and everything is
// and everything is right in php...
url : _path + "/core/ajax.php",
type : 'POST',
data : { f: 'getCharacter', i: id },
dataType : 'json',
success : function(data) {
if(data.error){
$('body').html(data.error);
}else{
$('.sel_info_top').html(data.info);
$('.sel_info_description').html(data.desc);
$('.skill_tree').html(data.skills);
$('.sel_information_container').show('slide', {direction: 'down'}, 'slow');
}
}
});
// ajaxSend, always, ajaxStart, all not working with this...
request.ajaxSend(cleanInfo());
}
解決策はありますか?