jquery $post 帖子页面,但 Request.Form 为 null

发布于 2024-07-25 17:37:35 字数 191 浏览 3 评论 0原文

我的表单中只有几个输入字段。 经过一番验证后,我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

始终不够 2024-08-01 17:37:35

如果这

$.post("Myproduct.aspx?action=1");

是唯一要发布的内容,那么也就不足为奇了,因为您只是缺少 post 参数( $.post() 函数中的第二个参数)。 你可能想要这样的东西:

var post_data = { 'key':'value', 'key2':'value2' } //or just some sort of data reading from a form
$.post("Myproduct.aspx?action=1",post_data);

if the

$.post("Myproduct.aspx?action=1");

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:

var post_data = { 'key':'value', 'key2':'value2' } //or just some sort of data reading from a form
$.post("Myproduct.aspx?action=1",post_data);
涙—继续流 2024-08-01 17:37:35

好的,所以此文档位于 http://docs.jquery.com/Ajax/jQuery .post

$.post(url, data, callback, type)

这就是 $.post 的样子,第一个参数 url 是必需的,第二个参数则不需要。 因此,如果您想发布一些数据,您需要添加一个对象:

$.post("Myproduct.aspx?action=1", {"key1": data1, "key2": data2});

如果您正在执行此跨域操作,则需要使用 JSONP,但这需要一些额外的工作,包括 JavaScript 以及服务器返回数据的方式。

Okay, so the doc for this is at http://docs.jquery.com/Ajax/jQuery.post

$.post(url, data, callback, type)

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:

$.post("Myproduct.aspx?action=1", {"key1": data1, "key2": data2});

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.

2024-08-01 17:37:35

您应该查看 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文