Javascript 表单不会提交 [英] Javascript form won't submit

查看:23
本文介绍了Javascript 表单不会提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在使用 http://www.hoppinger.com/blog/2010/05/28/file-upload-progress-bar-with-phpapc-and-javascript/ 并已申请它我的一个表格,当进度表工作时,成功上传时不会触发提交功能.

I have been using the uploader as provided by http://www.hoppinger.com/blog/2010/05/28/file-upload-progress-bar-with-phpapc-and-javascript/ and have since applied it to one of my forms and whilst the progress meter works, the submit function doesn't fire on successful upload.

我使用的完整代码如下:

The full code of what I am using is below:

JS
get_progress.php
uploader.php

据我所知,以我有限的经验,这是处理提交的函数:

As far as I can tell, in my limited experience, this is the function that handles the submit:

postUpload : function(o_data)
{
    // Loop through every input and set json response in hidden input
    this.a_inputs.each((function(o_input)
        {
            var s_name = o_input.get('name');
            var s_value = '';

            if(o_file = o_data.files[s_name])
            {
                s_value = JSON.encode(o_file);
            }


            var o_jsonInput = new Element('input',{'type': 'hidden','name':o_input.origName,'value':s_value}).replaces(o_input);


        }).bind(this));

    // Make form "original" again by purging elements and resetting attributes
    this.revertSubmit();
    this.o_form.submit();
},

我注意到提交的是 this.o_form.submit(); 而不是 this.form.submit(); 并检查出来,他已经声明 o_form : {} 在类的顶部,所以我认为他的语法是正确的,但我不知道.

I noticed that the submit was this.o_form.submit(); rather than this.form.submit(); and checked it out and he has declared o_form : {} at the top of the class, so I assume that his syntax is correct but I have no real idea.

在我实施这个进度跟踪器之前,表单工作得很好,所以这让我很沮丧.

Prior to my implementing this progress tracker the form worked perfectly, so this has got me quite frustrated.

基本上是哪里出了问题,我只能假设它是像缺少 ; 或类似错误一样简单的事情.

Essentially what has gone wrong, I can only assume that it's something as simple as a missing ; or similar mistake.

如果您在提交时收到 404,则表示它有效.我已暂时取消阻止该页面以进行故障排除.

If you get a 404 on the submit that means it worked. I have temporarily unblocked the page for troubleshooting.

因为这可能是相关的,我的网站使用 WordPress.

As it may be relevant, my site uses WordPress.

推荐答案

结果是 javascript 没有将 APC_UPLOAD_PROGRESS 标签添加到表单中,所以我添加了以下 jQuery 初始化后:

It turned out that the javascript wasn't adding the APC_UPLOAD_PROGRESS tag to the form so I added the following jQuery after the initilisation:

<script type="text/javascript">
    jQuery(document).ready(function(){

        var id = jQuery("form").attr('id');

        jQuery("form").submit(function(){

            jQuery(this).append("<input type=\"hidden\" name=\"APC_UPLOAD_PROGRESS\" value=\""+id+"\" />");

        });

    });

</script>

现在一切都好了.

这篇关于Javascript 表单不会提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆