Ween  Hello
Ween Hello

Reputation: 1

jquery.form.js plugin fileupload success callback function doesn't work in IE

jquery.form.js plugin fileupload success callback function doesn't work in IE.

fileupload success callback worked in chrome, firefox, safari.

I don't know why "SUCCESS callback function" doesn't work in IE ( IE9, IE8, IE7 also.. )

Here is my code < jQuery Form Plugin * version: 3.23 (11-DEC-2012) >

<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <script type="text/javascript" charset="utf-8" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>

    <script type="text/javascript">
        function func_beforeSubmit() {
        }
        function func_success(data) {
            alert(data);
        }
        function func_complete(xhr) {
            alert(xhr.responseText);
        }

        jQuery(document).ready(function() {
            var options = {
                clearForm       :   true,        // clear all form fields after successful submit         
                resetForm       :   true,        // reset the form after successful submit
                url             :   "url <-- just return text string",
                type            :   'post',
                dataType        :   'text',
                beforeSubmit    :   func_beforeSubmit,
                success         :   func_success,
                complete        :   func_complete
            };

            jQuery('#btn_file_upload_ajax').change(function() { jQuery('#frm_upload_ajax').submit(); });
            jQuery('#frm_upload_ajax').ajaxForm(options);
        });

    </script>
</head>
<body>
    <form id="frm_upload_ajax" method="post" enctype="multipart/form-data">
        <input type="file" name="attach_imgfile_ajax" id="btn_file_upload_ajax" ><br>
        <input type="hidden" id="data" name="data"/>
    </form>
    <hr><br>
            <div id="image_upload_preview"></div>
</body>

Upvotes: 0

Views: 5923

Answers (1)

Bumptious Q Bangwhistle
Bumptious Q Bangwhistle

Reputation: 4759

See this question, which deals with a similar problem.

You're uploading a file with AJAX, which can can cause problems in IE. See this page of the jquery.form.js documentation, which will almost certainly solve your problem.

In short, you'll need to determine if the browser is using the XMLHttpRequest object, and if it is not, return your result in a <textarea> and set the content-type to text/html to prevent IE from displaying an Open/Save dialog box.

Upvotes: 0

Related Questions