簡體   English   中英

如何在此函數中調用事件jQuery-File-Upload?

[英]How to call event jQuery-File-Upload in this function?

我想先從api檢查文件,然后再上傳文件

$('.file_upload_button_wrapper').live('click', function () {
        // check here
        $.ajax({
            url: '/?app=files&getfile=ajax%2Fupload.php',
            dataType: "json",
            success: function(data) {
                //$('.result').html(data);

                if (data.data.message =="DAT"){

                    $.confirm({
                        'title'     : 'Lỗi',
                        'message'   : 'Tài khoản đã hết hạn sử dụng. <br />Bạn có muốn gia hạn để tiếp tục upload ?',
                        'buttons'   : {
                            'Yes'   : {
                                'class' : 'blue',
                                'action': function(){
                                    window.location="http://id.kgp.vn";

                                }
                            },
                            'No'    : {
                                'class' : 'gray',
                                'action': function(){}  // Nothing to do in this case. You can as well omit the action property.
                            }
                        }

                    });

                }

                else{

                    $('.file_upload_start').trigger('click');
                }

            }

        });
 // $('.file_upload_start').trigger('click');
return false;
    });

而且我有打開文件並上傳的功能。

$(function () {
        $('.file_upload_start').fileupload({
            dropZone:$('#content'), // restrict dropZone to content div
            add:function (e, data) {
                var files = data.files;
                var totalSize = 0;

                if (files) {

....

當在ajax中成功調用此函數時出現問題,因為ajax首先檢查該上傳文件之后。

if I call $('.file_upload_start').trigger('click'); 在成功的ajax它不起作用,但我打電話

$('.file_upload_button_wrapper').live('click', function () { }

有用。

如何在ajax中調用此事件?

我已經通過在ajax中分配async:False解決了這個問題,並且效果很好。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM