使用AJAX上传和删除上传文件时,请求不会结束

时间:2013-03-27 06:57:45

标签: php ajax symfony

由于版权问题,我无法提供完整的源代码,但我会详细描述问题。

我使用AJAX上传来上传文件。一切都很好,除了当我choose a file, delete it outside then submit it时,请求不会结束。问题发生在Firefox上。这就是数字:

enter image description here

public function inputAction()
{
    // Get request.
    $request = Request::createFromGlobals();

    if($request->getMethod() == "POST" && $request->request->has("uploadFile")) {
        var_dump("It should output this"); exit();

        // In practice, It will run to this.
        $request->request->set("finish", true);
    }

    // Set this to close loading dialog.
    $request->request->set("finish", false);

    // Render view.
    return $this->render('frontendfrontBundle:Convert:input.html.php', array("bag" => $request->request));
}

我的表格

            <form id="convertForm" method="post" action="<?php echo $view['router']->generate('Convert_input');?>" enctype="multipart/form-data" target="upload_target">

            <!-- Used for file uploading -->
            <iframe id="upload_target" name="upload_target" src="#" style="width:0;height:0;border:0px solid #fff;"></iframe> 

            <input id="uploadFile" type="file" class="width_txt" name="uploadFile"/>

            </form>

    <?php
        if($bag->get("finish", false) == true) {
    ?>
        <script>
            $(document).ready(function() {
                window.parent.stopUpload();                 
            });                  
        </script>
    <?php } ?>

JAVASCRIPT

$("#convertForm").submit(function(e) { // onSubmit()
        startUpload();
});

0 个答案:

没有答案