我正在使用 jquery 将图像上传到 joomla 站点,但是文件 ajaxfileupload.js 有问题。图片上传得很好,但“成功”中的函数没有被调用。我需要它来显示上传完成的确认。我尝试使用“完成”而不是“成功”,然后代码可以工作,但它会一遍又一遍地刷新页面。我怎样才能让它像它应该的那样工作?这是代码..
upload: function (a) {
if (jQuery("#Filedata-" + a).val() == "") {
jQuery("#photoupload-" + a).remove();
joms.uploader.upload();
if (jQuery("#photoupload").next().length == 0) {
joms.uploader.addNewUpload()
}
jQuery("#upload-photos-button").show();
return
}
var c = (jQuery("#photoupload-" + a + " :input:checked").val() == "1") ? "&defaultphoto=1" : "";
var b = jQuery("#photoupload-" + a).next().find(".elementIndex").val();
b = (b != "") ? "&nextupload=" + b : "";
jQuery("#photoupload-" + a).children().each(function () {
jQuery(this).css("display", "none")
});
jQuery("#photoupload-" + a).append('<div id="photoupload-loading-' + a + '"><span class="loading" style="display:block;float: none;margin: 0px;"></span><span>' + joms.uploader.uploadText + "</span></div>");
jQuery.ajaxFileUpload({
url: this.postUrl + c + b,
secureuri: false,
fileElementId: "Filedata-" + a,
dataType: "json",
success: function (e, d) {
jQuery("#photoupload-loading-" + a).remove();
if (typeof (e.error) != "undefined" && e.error == "true") {
jQuery("#photoupload-" + a).css("background", "#ffeded");
jQuery("#photoupload-" + a).append('<span class="error">' + e.msg + "</span>")
} else {
jQuery("#photoupload-" + a).css("background", "#edfff3");
jQuery("#photoupload-" + a).append('<span class="success">' + e.msg + "</span>")
}
jQuery("#photoupload-" + a).fadeOut(4500, function () {
jQuery("#photoupload-" + a).remove();
if (jQuery("#photoupload").next().length == 0) {
joms.uploader.addNewUpload()
}
});
jQuery("#photoupload-" + a + " .remove").css("display", "block");
if (e.nextupload != "undefined") {
joms.uploader.upload(e.nextupload);
return
} else {
jQuery("#upload-photos-button").show()
}
},
error: function (f, d, g) {}
});
return false
}