jquery 1.7 无法将表单提交到特定 URL
jquery 1.7 cant submit the form to specific url
我想使用 $.post
将表单提交到特定 URL,我完全按照教程告诉我的去做。 这是我的代码
$(document).ready(function () {
$("#fLogin").on('submit', function (e) {
var errorCount = 0;
$('span.errorMessage').text('');
$('input [type=text]').each(function () {
var $this = $(this);
if ($this.val() === '') {
var error = 'Please fill ' + $this.prev('label').text(); // take the input field from label
$this.next('span').text(error);
errorCount = errorCount + 1;
}
});
var select = $('#sUserType').filter(function () {
if (this.selectedIndex == 0)
errorCount = errorCount +1;
return this.selectedIndex == 0;
}).next('span').text('Please select user type');
if (errorCount == 0) {
var mobileNumber = $("#iMobileNumber").val();
var password = $("#iPassword").val();
$.post("MY URL");
//$.ajax("ajax/test.html", function (data) {
// alert("d");
//});
}
else
e.preventDefault();
});
});
但是当我按下提交按钮时,我只是在 URL 中有新的问号,我的意思是这个
提交前表单的网址
http://localhost:42344/WebForm1.aspx
提交后表单的网址
http://localhost:42344/WebForm1.aspx?
我做错了什么?
注意
我可以更改密码和手机号码的值
您正在使用没有回调的 $.post,那么您期望看到什么?Post将在后台运行,因为它是一个异步HTTP(Ajax)请求。也许您正在寻找:
$('form').attr('action', "/yoururl").submit();
http://api.jquery.com/submit/
相关文章:
- 表单提交问题,如何在我的URL末尾获得ID的值
- 我想知道如何只激活表单提交,而不获取jquery中ajax url的值
- 如果文本字段不为空,则自动将表单提交到url
- 使用ajax发布表单,然后将相同的表单提交到其他url
- 页面重定向,在表单提交时传递引用 URL
- 在表单提交时使用 URL 发送路由参数
- jquery 1.7 无法将表单提交到特定 URL
- Dropzone JS 等到 ajax 表单提交并更改 options.url
- 使用 jQuery 在表单提交时将隐藏的输入值设置为数据 URL
- Ajax 表单提交到 PHP 文件和 URL
- 在表单提交后将 get 变量附加到 url,而无需新的隐藏输入
- 表单提交会附加URL
- 如何避免表单提交后出现不希望的URL地址更改
- 表单提交将取消URL查询字符串中的一个参数
- Struts表单提交URL
- 将详细信息发送到数据库后,正在将表单提交重定向到URL
- 当URL中存在查询字符串时,Jquery表单提交无法工作
- PHP表单提交,然后检查url以显示相应的内容
- 为什么多个表单提交点击不调用url多次
- AJAX将表单提交到远程URL,并从XML响应中提取URL