表单没有使用jquery提交
Form not getting submitted using jquery
我正在尝试使用oAuth 2.0验证用户,它工作良好,我使用jquery从谷歌获取用户信息,我想发送到下一页。为此,我使用jQuery编程生成表单并提交表单。但不幸的是,表单没有提交。我已经看到了堆栈溢出的各种答案,并试图实现使用的东西,但没有一个是工作的。
这是我的代码。
customButtonRender.js
function onSuccess(googleUser){
console.log('Logged in as '+googleUser.getBasicProfile().getName());
var profile = googleUser.getBasicProfile();
submit_form(profile);
}
var submit_form = function(profile){
console.log(profile.getId());
console.log(profile.getName());
console.log(profile.getImageUrl());
console.log(profile.getEmail());
var user_url = "localhost:8080/NUConnect_JSP/jsp/home.jsp";
var val_form = $('<form data-ajax="false" method="POST" id="val_form" action="' + user_url + '">'+
'<input type="text" name="user_name" value="' + profile.getName() + '">'+
'<input type="text" name="user_email" value="' + profile.getEmail() + '">'+
'<input type="submit" name="user_submit" id="user_submit">'+
'</form>');
$('body').append(val_form);
// $("#val_form").submit();
// $("#val_form")[0].submit();
// $("#user_submit").click();
document.getElementById("val_form").submit();
console.log("After submit");
};
我已经在标题部分包含了customButtonRender.js文件。
正如你所看到的,我已经尝试了各种方法来提交写在评论中的表单,但没有一个有效。
所有日志打印成功。
如果你的数据不是那么机密那么在你的url中像这样传递信息
window.location.href = "localhost:8080/NUConnect_JSP/jsp/home.jsp?user_name="+profile.getName()+"&user_email="+ profile.getEmail();
相关文章:
- Jquery提交表单而不刷新
- 带有select的jquery提交表单不起作用
- 调用DOM提交方法时未激发jQuery提交事件
- Rails jQuery.提交后如何重置表单
- addEventListener提交和jQuery提交
- 使用 jQuery 提交通过 Ajax 加载的表单
- Jquery 提交表单,在成功提交表单到 php 后添加
- 通过jquery提交(smarty)
- 处理jQuery提交表单的两种方法
- 使用jQuery提交表单时的竞争条件
- jquery提交表单,带有事件更改按钮
- 从jQuery提交不起作用
- 为什么不'jquery提交工作正常
- Jquery提交函数未验证
- 多克隆选择菜单以使用Jquery提交表单
- Jquery提交表单已损坏
- 不要在使用 ajax 和 jquery 提交表单后重新加载页面
- 使用jquery提交表单,该表单具有多个提交按钮,无需单击触发器
- 禁用和重新启用表单 在 Rails 中使用 JQuery 提交
- 使用 JS/Jquery 提交带有按钮的表单