Drupal jquery 提交表单,无需提交按钮
我有一个 drupal 表单,当您从选择列表(一种快速搜索选择列表)中选择一个选项时,我会使用 jquery 发布该表单。
问题是,当我通过单击按钮提交时,它起作用了。 当我使用 jquery,并且按钮位于表单中(隐藏或不隐藏)时,它可以工作。 当我使用 jquery 并移动按钮时,帖子已完成,但“FORM_submit”函数未被调用,它只是刷新我的页面。
谁能解释这种行为?
@编辑:
奇怪的是,我在想:因为你有多个按钮,也许你也必须将按钮作为参数发布。但是当我扫描帖子时,不包括该按钮:
Parametersapplication/x-www-form-urlencoded
form_build_id form-138a553d76a89c82e09a231a2f55e8a9
form_id duration_search_form
keyword 103
Source
Content-Type: application/x-www-form-urlencoded Content-Length: 92 keyword=103&form_build_id=form-138a553d76a89c82e09a231a2f55e8a9&form_id=duration_search_form
尽管如此,这是带有 jquery 提交功能和隐藏按钮的,并且它可以工作
I have a drupal form which i post using jquery when you select an option from a selectlist (a sort of quicksearch selectlist).
The porblem is that when i submit by clicking the button, it works.
When I use jquery, and the button is in the form (hidden or not), it works.
When I use jquery and I rmove the button, the post is done, but the "FORM_submit" function is not called and it just refreshes my page.
Can anyone explain this behaviour ?
@edit:
The strange thing is, I was thinking: because you have multiple buttons maybe you have to post the button as a parameter as well. But when I scan trough the posts, the button is not included:
Parametersapplication/x-www-form-urlencoded
form_build_id form-138a553d76a89c82e09a231a2f55e8a9
form_id duration_search_form
keyword 103
Source
Content-Type: application/x-www-form-urlencoded Content-Length: 92 keyword=103&form_build_id=form-138a553d76a89c82e09a231a2f55e8a9&form_id=duration_search_form
Altough, this is with a jquery submit function, and a hidden button, and it works
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为您还必须发布提交按钮的值。下面是我在 bubbletimer-6.x-2.x 中的操作示例:
完整文件: http://drupalcode.org/viewvc/drupal/contributions/modules/bubbletimer/bubbletimer_ahah.js?view=markup&pathrev=DRUPAL-6 --2
This is because you have to post the value of the submit button also. Here comes an example how I did it in bubbletimer-6.x-2.x:
Full file: http://drupalcode.org/viewvc/drupal/contributions/modules/bubbletimer/bubbletimer_ahah.js?view=markup&pathrev=DRUPAL-6--2