简体   繁体   中英

Open file upload dialog after Ajax post success

I have functionality in which it is required to open file upload dialog after Ajax call success event.

What I tried: I tried applying below simple code in ajax success: and complete: event but it is not working.

$.ajax({
        url: url,
        type: 'GET',
        dataType: 'json',
        data: { id: eoid },
        contentType: 'application/json; charset=utf-8',
        success: function (data) {
            // some logic
            $("#fileupload").click();
        }
    });

What is problem: If I put simple button and try to execute above code, it is working fine and opening dialog - but it is not working in case of ajax post afterwards .

Any guesses or am I missing something?

Thank you.

The problem is at dataType: 'json' . You are loading html with your ajax request so you should change it to dataType: 'html' else in any other format it will not be considered success. Or you can delete this property as stated in Jquery doc that Jquery does default: Intelligent Guess (xml, json, script, or html) .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM