Got a problem - little help pls.
Hello all.
I have a problem with ajax requests.
I want to delete some things over json ajax request and it works fine
but when I start to delete another one somehow it remembers previous
url and it dispatch 2 requests or even more simultaneously.
I have Administrators, Bots, Guests and for example Test 1 and test 2.
When I click on delete for example Administrators, it wont allow me
because i disallow it. Than I press ok and for example try to delete
test 1 and it first it says me that I cannot delete this group
( remembered from administrator ) and than it just delete the second
group without any notice.
Okay this is the code. It's a little bit fuked up. I will repair it
but still i'm noob in jquery.
hackurl is defined globally as false
function deleteItem( id, div, hackurl ){
$j('#process_li').fadeIn('fast');
$j('#preloadimg').addClass('hidden');
$j('#preloadimg_bad').addClass('hidden');
$j('#preloadimg_success').addClass('hidden');
$j('#warningimg').removeClass('hidden');
$j('#preloadtitle').text('Are you sure?');
$j('#preloadmessage').text('You have been requested to delete
policy! Are you sure that you want to process with deletion?');
hackurl = false;
hackurl = $j("#"+id).attr("href");
$j("#progressarea").fadeIn(100, function(){
$j("#progressarea .progresssection").fadeIn("fast");
});
$j("#discarge_alert").bind("click", function(){
$j("#progressarea .progresssection").fadeOut("fast", function(){
$j("#progressarea").fadeOut( 100 );
});
return false;
});
$j("#process_to_alert").bind("click", function(){
$j.ajax({
type: "POST",
url: hackurl,
cache: false,
dataType: "json",
beforeSend: function(XMLHttpRequest){
$j('#process_li').fadeOut('slow');
$j('#warningimg').addClass('hidden');
$j('#preloadimg_bad').addClass('hidden');
$j('#preloadimg').removeClass('hidden');
$j('#preloadtitle').text('Please wait...');
$j('#preloadmessage').text('Waiting for server response about
your task...');
},
error: function( XMLHttpRequest, textStatus, errorThrown ){
$j('#warningimg').addClass('hidden');
$j('#preloadimg').addClass('hidden');
$j('#preloadimg_bad').removeClass('hidden');
$j('#preloadtitle').text('Script error!');
$j('#preloadmessage').text('Error with the script occured!
Please contact administrators!');
},
success: function( data, textStatus ){
if( data.state == 'false' )
{
$j('#warningimg').addClass('hidden');
$j('#preloadimg').addClass('hidden');
$j('#preloadimg_bad').removeClass('hidden');
$j('#preloadtitle').text(data.title);
$j('#preloadmessage').text(data.message);
}
if( data.state == 'true' )
{
$j('#process_cancel_li').fadeOut('slow');
$j('#warningimg').addClass('hidden');
$j('#preloadimg').addClass('hidden');
$j('#preloadimg_bad').addClass('hidden');
$j('#preloadimg_success').removeClass('hidden');
$j('#preloadtitle').text(data.title);
$j('#preloadmessage').text(data.message);
$j("."+div).fadeOut('slow');
setTimeout('$j("#progressarea").fadeOut("slow");', 3000 );
}
}
});
return false;
});
return false;
}
Thanks a lot for any help.
Cheers.