【问题标题】:AJAX form not returning data when using input file使用输入文件时 AJAX 表单不返回数据
【发布时间】:2014-01-29 11:33:26
【问题描述】:

我遇到了一个奇怪的问题。我有这个表格,基本上它只是将数据发送到另一个处理输入和更新数据库的 cfm 文件。今天我添加了一个输入类型=“文件”,以便从中处理 EXIF 数据并提取 GPS 信息。结果页面会将一个 div 复制到指定的目标 div。一切正常,数据被提取和更新,但带有响应的 div 不再出现。一旦我删除 input="file" div 目标 div 就会更新。似乎是响应头问题,但我不知道如何解决它。谢谢。

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.js"></script> 
<script src="http://malsup.github.com/jquery.form.js"></script>
<script> 
    $(document).ready(function() { 
        // bind form using ajaxForm 
        $('#sede-form').ajaxForm({ 
            // target identifies the element(s) to update with the server response 
            target: '#htmlExampleTarget', 
            // success identifies the function to invoke when the server response 
            // has been received; here we apply a fade-in effect to the new content 
            success: function() { 
                $('#htmlExampleTarget').fadeIn('slow'); 
            } 
        }); 
    });
</script> 
<cfoutput query="dett_cli">                 
    <form id="sede-form" enctype="multipart/form-data" action="modifica_sede_response.cfm" method="post" class="form-inline">
        <input type="hidden" name="codice" value="#url.codice#" />
        <input type="hidden" name="id_sede" value="#url.id_sede#" />
        ... [other fields]...
        <input type="hidden" name="sed_coordinate_o" value="#sed_coordinate#" class="input-large">  
        <div class="control-group">
            <label class="control-label" for="sed_coordinate">JPG Coordinate GPS </label>
            <div class="controls">
                <div class="input-prepend">
                    <input type="file" name="sed_coordinate" id="sed_coordinate" class="input-large">   
                </div>
            </div>
        </div>
        ... [other fields]...
        <!-- END div.row-fluid -->
        <div class="form-actions">
            <button type="reset" class="btn btn-danger"><i class="icon-repeat"></i> Resetta</button>
            <button type="submit" class="btn btn-success"><i class="icon-ok"></i> Aggiorna</button>
            <div  id="htmlExampleTarget"></div>
        </div>
    </form>
</cfoutput>

【问题讨论】:

    标签: ajax file upload response


    【解决方案1】:

    尝试将以下内容放回您的 ajaxForm 选项中。

    iframe:true,
    forceSync:true,
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-05
      • 1970-01-01
      • 2018-01-05
      • 1970-01-01
      • 2012-06-12
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多