FINEUPLOAD pass the ID as parameter

≡放荡痞女 提交于 2019-12-12 03:56:15

问题


i got this divs

<div id="thumbnail-uploader_1" class="thumbnail-uploader">
<div id="thumbnail-uploader_2" class="thumbnail-uploader">

and this Jquery call

$('.thumbnail-uploader').fineUploader({
request: {
    endpoint: '/core/ajax/add_avatar.php',
    params: {
    one: function() {
        return this.id;
     }
    }
},
multiple: false,
validation: {
    allowedExtensions: ['jpeg', 'jpg', 'gif', 'png'],
    sizeLimit: 551200 // 50 kB = 50 * 1024 bytes
},
text: {
    uploadButton: 'Klikněte nebo sem přetáhněte soubor'
}
}).on('complete', function(event, id, fileName, responseJSON) {
if (responseJSON.success) {
    $(this).append('<img src="/uploads/categories/' + fileName + '" alt="' + fileName + '">');
    $('.qq-upload-list').fadeOut(2500);
}
});

all i want to do is to pass the ID of the used uploader. but with this call, i got undefined value of the parameter "one" when i try to use it in "add_avatar.php" which is handler. i use the global array REQUEST over there to check if the value pass. but its undefined.

does anyone have some idea how to pass the ID in my php script? i will have more instances of this uploader there so i have to check for which record im changing the avatar.


回答1:


i solved it by creating the jquery calls for every iterations of category and i changed the selector from class to ID like:

$('#thumbnail-uploader_1').fineUploader({.....
$('#thumbnail-uploader_2').fineUploader({.....



回答2:


Since you are using jQuery, maybe this is what you are looking for.

return $(this).attr('id');


来源:https://stackoverflow.com/questions/16158976/fineupload-pass-the-id-as-parameter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!