Unable to add a project and gets weird access denied messages
I created an account to create a new plugin (or actually it's a fix but since the author is not active anymore...) and wanted to upload my new plugin. Everything got kind of weird from that and the site was completely weird and gave me access denied messages when I tried to go to the Plugins page (
http://plugins.jquery.com/ ) when logged in. If I log out there is no problem.
Anyway, I don't really care that much but I wanted to share an update on a smart, easy plugin created by mr Reisig himself a bunch of years ago, the Ajax Queue / Ajax Sync plugin. All error-callbacks got fired regardless if they should've been or not and my solution fixes that problem. Feel free to share.
- /*
* Queued Ajax requests.
* A new Ajax request won't be started until the previous queued
* request has finished.
*/
jQuery.ajaxQueue = function(o){
var _old = o.complete;
o.complete = function(){
if ( _old ) _old.apply( this, arguments );
jQuery.dequeue( jQuery.ajaxQueue, "ajax" );
};
jQuery([ jQuery.ajaxQueue ]).queue("ajax", function(){
jQuery.ajax( o );
});
};
/*
* Synced Ajax requests.
* The Ajax request will happen as soon as you call this method, but
* the callbacks (success/error/complete) won't fire until all previous
* synced requests have been completed.
*/
jQuery.ajaxSync = function(o){
var fn = jQuery.ajaxSync.fn, data = jQuery.ajaxSync.data, pos = fn.length;
fn[ pos ] = {
error: o.error,
success: o.success,
complete: o.complete,
done: false
};
data[ pos ] = {
error: [],
success: [],
complete: []
};
o.error = function(){ data[ pos ].error = arguments; };
o.success = function(){ data[ pos ].success = arguments; };
o.complete = function(){
data[ pos ].complete = arguments;
fn[ pos ].done = true;
if ( pos == 0 || !fn[ pos-1 ] )
for ( var i = pos; i < fn.length && fn[i].done; i++ ) {
if ( fn[i].error && data[i].error.length > 0 ) fn[i].error.apply( jQuery, data[i].error );
if ( fn[i].success && data[i].success.length > 0 ) fn[i].success.apply( jQuery, data[i].success );
if ( fn[i].complete && data[i].complete.length > 0 ) fn[i].complete.apply( jQuery, data[i].complete );
fn[i] = null;
data[i] = null;
}
};
return jQuery.ajax(o);
};
jQuery.ajaxSync.fn = [];
jQuery.ajaxSync.data = [];