jquery $post 帖子页面,但 Request.Form 为 null
我的表单中只有几个输入字段。 经过一番验证后,我使用 jquery 来发布页面。
$.post("Myproduct.aspx?action=1");
该帖子似乎已通过。 但是当我调试服务器代码时, request.form[] 为空。
有人遇到过这个问题吗?
I have few input fields in a form. after some validation, I use jquery to post the page.
$.post("Myproduct.aspx?action=1");
The post appears to go through. But when I debug the server code,
the request.form[] is null.
Has any one had this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
如果这
是唯一要发布的内容,那么也就不足为奇了,因为您只是缺少 post 参数( $.post() 函数中的第二个参数)。 你可能想要这样的东西:
if the
is the only thing that is being posted, then no wonder, because you are simply missing the post parameters (the second parameter in the $.post() function). You probably want something like this:
好的,所以此文档位于 http://docs.jquery.com/Ajax/jQuery .post
这就是 $.post 的样子,第一个参数 url 是必需的,第二个参数则不需要。 因此,如果您想发布一些数据,您需要添加一个对象:
如果您正在执行此跨域操作,则需要使用 JSONP,但这需要一些额外的工作,包括 JavaScript 以及服务器返回数据的方式。
Okay, so the doc for this is at http://docs.jquery.com/Ajax/jQuery.post
This is how $.post looks, the first parameter the url is required the second where you put the data is not. So if you want to post some data you would do add an object:
If you are doing this cross domain you would need to use JSONP, but that requires some extra work, both on the javascript and how the server returns the data.
您应该查看 JQuery Forms 插件。 它将处理从表单中为您构建数据参数的所有脏活。 超级快,而且简单。
You should check out the JQuery Forms plugin. It will handle all the dirty work of building the data parameter for you from your form. Super fast, and easy as can be.