Сегодня занимался обновлением скрипта uploadify.js, который использую для загрузки файлов в моем мультимедийном расширении Commedia для CMS Joomla. Исправил в двух местах $ на jQuery, но вот с одной ошибкой я провозился часа полтора.
Речь об ошибке
"this.cancelUpload is not a function"
в строке 937:
this.cancelUpload(file.id);
Кусок кода выглядит так:
	$.ajax({
	                    type    : 'POST',
	                    async   : false,
	                    url     : settings.checkExisting,
	                    data    : {filename: file.name},
	                    success : function(data) {
	                        if (data == 1) {
	                            var overwrite = confirm('A file with the name "' + file.name + '" already exists on the server.\nWould you like to replace the existing file?');
	                            if (!overwrite) {
	                                 this.cancelUpload(file.id);
	                                $('#' + file.id).remove();
	                                if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) {
	                                    if (this.queueData.uploadQueue[0] == '*') {
	                                        this.startUpload();
	                                    } else {
	                                        this.startUpload(this.queueData.uploadQueue.shift());
	                                    }
	                                }
	                            }
	                        }
	                    }
	                });
Оказалось, что скрипт не видит this внутри ajax запроса. Точнее он его переопределяет. Чтобы скрипт этого не делал, нужно использовать опцию contex, то есть код должен выглядеть так:
	$.ajax({
	                    context: this,
	                    type    : 'POST',
	                    async   : false,
	                    url     : settings.checkExisting,
	                    data    : {filename: file.name},
	                    success : function(data) {
	                        if (data == 1) {
	                            var overwrite = confirm('A file with the name "' + file.name + '" already exists on the server.\nWould you like to replace the existing file?');
	                            if (!overwrite) {
	                                 this.cancelUpload(file.id);
	                                $('#' + file.id).remove();
	                                if (this.queueData.uploadQueue.length > 0 && this.queueData.queueLength > 0) {
	                                    if (this.queueData.uploadQueue[0] == '*') {
	                                        this.startUpload();
	                                    } else {
	                                        this.startUpload(this.queueData.uploadQueue.shift());
	                                    }
	                                }
	                            }
	                        }
	                    }
	                });

 
						
