Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript IE8正在将表单提交到当前页面_Javascript_Jquery_Ajax_Iframe_File Upload - Fatal编程技术网

Javascript IE8正在将表单提交到当前页面

Javascript IE8正在将表单提交到当前页面,javascript,jquery,ajax,iframe,file-upload,Javascript,Jquery,Ajax,Iframe,File Upload,它在所有其他浏览器中都能工作,以前也在IE8上工作过,但我做了一些代码清理并移动了一些东西,现在它将此表单提交给它自己。这是一个ajax上传程序是的,不是真正的ajax,但你知道我的意思 以下是JS: function file_upload($theform,item_id){ $theform.attr('ACTION','io.cfm?action=updateitemfile&item_id='+item_id); if($theform.find('[type=

它在所有其他浏览器中都能工作,以前也在IE8上工作过,但我做了一些代码清理并移动了一些东西,现在它将此表单提交给它自己。这是一个ajax上传程序是的,不是真正的ajax,但你知道我的意思

以下是JS:

function file_upload($theform,item_id){
    $theform.attr('ACTION','io.cfm?action=updateitemfile&item_id='+item_id);
    if($theform.find('[type=file]').val().length > 0){
        $('iframe').one('load',function(){
            $livepreview.agenda({
                action:'get',
                id:item_id,
                type:'item',
                callback:function(json){
                    $theform.siblings('.upload_output').append('<li style="display:none" class="file-upload"><a target="blank" href="io.cfm?action=getitemfile&item_file_id='+json[0].files.slice(-1)[0].item_file_id+'">'+json[0].files.slice(-1)[0].file_name+'</a> <a style="color:red" title="Delete file?" href="#deletefile-'+json[0].files.slice(-1)[0].item_file_id+'">[X]</a></li>').children('li').fadeIn();
                    $theform.siblings('.upload_output').find('.nofiles').remove();
                }
            });
            //Resets the file input. The only way to get it cross browser compatible as resetting the val to nothing
            //Doesn't work in IE8. It ignores val('') to reset it.
            $theform.append('<input type="reset" style="display:none">').children('[type=reset]').click().remove();
        });
    }
    else{
        $.alert('No file selected');
        return false;
    }
}
/* FILE UPLOAD EVENTS */
//When they select "upload" in the modal
$('.agenda-modal .file_upload').live('submit',function(event){de
    file_upload($('.agenda-modal .file_upload'),$('.agenda-modal').attr('data-defaultitemid'));
});
你应该返回false;在提交处理程序的末尾

啊,这很难理解。好的,这个定义在哪里?编辑-哦,我看到了


再次编辑-好的,我意识到我在这里的可信度有点像在薄冰上跳来跳去,但我建议在upload_目标中添加一个id属性作为id值。每隔一段时间,我就会确切地知道姓名和身份证中哪一项是重要的,以及什么时候/为什么重要,但这些信息只持续一个小时左右,我的大脑就会反常地忽略它。我所说的重要是指元素。

它应该将表单发送给自己

假设按钮类型为submit ie submits form automatically,且表单操作为空ie,请自行发送

但是,正如您所做的,提交处理程序可能会导致表单根本不提交,我想问,提交的目的是什么?但这已经过时了


无论如何,您应该停止事件传播并在事件处理程序中返回false。

相关页面是否包含基本标记?正如一个简单的测试页面所示,实际上不需要大写Firefox的action属性名称。不,它没有基本标记。对于动态变化的动作,它必须大写。我为此争论了好几天,stackoverflow上有人指出你必须利用它。@Pointy是正确的-操作不需要特别针对firefox,你可以在这里用firebug进行测试:这里:这不是一个动态添加的表单…如果处理程序返回false,jQuery将假定这意味着传播也将停止。没有理由同时做这两件事,当然这并不会伤害到任何东西。只是为了尝试一下,我在直播结束时添加了event.stopPropation。什么都没发生。。。即使在其他浏览器上,表单仍然会提交。我有一个问题,那就是停止输入文本框的键控。我建议两者都使用。显示iframe如何?我看到了隐藏iFrame根本不运行的问题。若要修复,请删除样式=显示:隐藏;并确保frameborder=0,width=1,height=1Hmm,必须以某种方式修改其他内容。。。iframe,i undisplay:none'd it,当我在FF或Chrome中上传内容时,它不会显示在JSON返回中,但文件已上载…返回false会使整个表单无法提交给我。它仍然需要提交,只是提交到iframe…实际上,你帮助了我,并告诉我不要太提交:哈哈!我觉得你的用户名听起来很熟悉:-好吧,我仍然在寻找和抓挠我的头有点…是的,你帮了我几次。很好地抓住了Firefox这个奇怪的东西。。。看起来很奇怪,它会把浏览器搞糊涂。但是知道这一点很好。等等,jQuery选择器引用了什么上传目标?我在任何代码中都看不到这一点。标签的目标应该只是普通的上传目标。
        <label>Add Attachment</label>
        <form class="file_upload" method="post" enctype="multipart/form-data" target="upload_target" action="">
            <input name="binary" id="file" size="27" type="file" /><br />
            <br><input type="submit" name="action" value="Upload" /><br />
            <iframe class="upload_target" name="upload_target" src="" style="display:none"></iframe>
        </form>
        <label>Attachments</label>
        <ul class="upload_output">
        <li class="nofiles">(No Files Added, Yet)</li>
        </ul>