重新提交相同的表单不起作用 [英] Resubmitting the same form is not working

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

问题描述

我正在制作一个HTML页面Login Pro.html。我做了这样一个页面,只需点击一个链接,我就可以登录到一个账户(比如Facebook)。



HTML代码:

 < a href =Login Pro.htmlid =loginLinktarget =_ new>登录我的帐户< / a> 

用户名和密码的表单输入字段(value属性将使用JQuery设置): p>

 < input type =textid =usernamevalue =/> 
< input type =passwordid =passwordvalue =/>
< input type =submitid =loginButton/>

在JQuery代码中,我设置值并提交表单,如下所示:

  $(#loginLink)。click(function()//当链接被点击时会执行
{
$(#username)。attr(value,My Username); //设置用户名
$(#password)。attr(value,我的密码); //设置密码
$(#loginButton)。click(); //通过隐式地点击提交按钮提交表单
});

在这种情况下,我可以成功登录我的帐户,并且Login Pro.html(从页面我正在做所有这些)正在打开一个新的页面(因为我已经设置了 target =_ new),表单正在提交并带我到账户主页登录时,在第一页(选项卡)中打开成功,但当我尝试通过Login Pro.html页面重新登录时,在新选项卡中打开,我正在登录到同一页面,即登录Pro.html页面而不是登录(简而言之,在第二个实例中,我无法登录)。关闭此页面后,当我再次打开页面时,同样的传奇继续,即我能够在第一个实例,但无法这样做,而尝试在新标签。

有人可以帮助我摆脱这种情况。这是因为,页面已经加载?

解决方案

如果没有名字,你不会发送任何东西。


I am making an HTML page "Login Pro.html". I am making such a page where just clicking on a link I can login to an account (say Facebook).

HTML Code:

<a href="Login Pro.html" id="loginLink" target="_new">Login to my Account</a>

The Form input fields for Username and Password (The value attribute will be set using JQuery):

<input type="text" id="username" value="" />
<input type="password" id="password" value="" />
<input type="submit" id="loginButton" />

In the JQuery code, I am setting the values and submitting the form like this:

$("#loginLink").click(function()//when the link is clicked this will be executed.
{
   $("#username").attr("value","My Username");//Setting value for the username
   $("#password").attr("value","My Password");//Setting value for the password
   $("#loginButton").click();//Submitting the form by implicitly clicking the submit button
});

In this case I am able to login into my account successfully and the "Login Pro.html"(From the Page I am doing all these) is opening in a new page (because I have set target="_new" and the form is being submitted and taking me to the Home Page of the Account I am logging in into, is opening successfully in the first page (tab). But when I am trying to login again through the "Login Pro.html" page, opened in the new tab, I am being landed to the same page i.e. "Login Pro.html" page instead of getting logged in (In short in the second instance I can't login). After closing this page, when I am opening the page again, the same saga continues i.e. I am able to login in the first instance, but not able to do so while trying in the new tab.

Can somebody help me in getting rid of this. Is this because, the page is already loaded?

解决方案

The "name" attribute is missing in the inputs. Without name you are not sending anything.

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

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