如何在表单提交后继续运行执行? [英] How to continue running execution after form submit?

查看:920
本文介绍了如何在表单提交后继续运行执行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在为特定网站编写一个简单的表单提交功能。
脚本填写当前页面上的特定表单并提交表单。它还必须填写第一个表格提交后出现的第二个表格,并提交此表格。

I am writing a simple form submit function for a specific site. The script fills the specific form on the current page and submits the form. It MUST also fill the second form which appears after the first form is submitted and submit this form too.

这是有2个表格必须填写并提交。

That is there are 2 forms that must be filled and submitted.

然而问题是,在正常页面上,脚本填充并填写第一个表单并提交它。提交后,脚本停止工作!我想继续执行!

Problem however, is that on a normal page the script fills and 1st form and submits it. After submission however, the script stops working! I want to continue execution!

我在一个有2帧的页面上做错了!大多数页面没有框架!

I've done it by mistake on a page that had 2 frames! most pages don't have frames!

function FillFirstForm(){
    doc=document;
    //Some code removed from above...Fill Values
    doc.forms[0].name.value = answerarray[1];
    doc.forms[0].address.value = answerarray[2];
    doc.forms[0].phone.value = answerarray[3];
    doc.forms[0].username.value = answerarray[4];

    //And Press Button
    doc.forms[0].submit.click();

    iTimer=setInterval(FillSecondForm,5000);
    return true;
}

function FillSecondForm(){
    clearInterval(iTimer);
    doc.forms[0].tags.value = answerarray[5];
    doc.forms[0].reference.value = answerarray[6];
    document.forms[0].submit.click();
    return true;
}


推荐答案

基本规则是经典表单提交会停止页面脚本的所有执行,并加载下一页。无法做任何事情。

The basic rule is that a classical form submission halts all execution of scripts of the page, and loads the next page. No way to do anything about that.

您可能必须切换到使用Ajax发送表单的内容。这将使当前页面保持活动状态,并允许您根据需要进行多次提交。

You may have to switch to sending your form's contents using Ajax. That will leave the current page alive, and allow you to do as many submits as you want to.

实现此目的的一种非常简单的方法是 jQuery表单插件。这需要花费大量的手动麻烦。

A very easy way to achieve this is the jQuery form plugin. It takes much of the manual hassle out of the process.

这篇关于如何在表单提交后继续运行执行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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