我怎样才能得到这将是没有提交所有提交的表单的价值观 [英] How can I get all a form's values that would be submitted without submitting

查看:73
本文介绍了我怎样才能得到这将是没有提交所有提交的表单的价值观的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有我的网页形式和我动态地添加控件使用Javascript / JQuery的形式。在某些时候,我需要在客户端作为一个集合或查询字符串形式的所有值。我并不想提交表单,因为我想通过表单值连同我在客户端后端WCF /阿贾克斯服务方法等信息。所以我试图找出如何捕获同一类型的集合的形式通常会发送到服务器,如果形式实际提交所有的值。我怀疑有一个简单的方法来捕捉这一点,但我很为难。

I have a form on my page and am dynamically adding controls to the form with Javascript/JQuery. At some point I need to get all the values in the form on the client side as a collection or a query string. I don't want to submit the form because I want to pass the form values along with other information that I have on the client to a back-end WCF/Ajax service method. So I'm trying to figure out how to capture all the values in the same type of collection that the form would normally send to the server if the form was actually submitted. I suspect there is an easy way to capture this, but I'm stumped.

推荐答案

了jQuery插件的形式提供了一个简单的方法来遍历窗体元素,并把它们放在查询字符串。任何其他你需要做的这些值也可能是很有用的。

The jquery form plugin offers an easy way to iterate over your form elements and put them in a query string. It might also be useful for whatever else you need to do with these values.

var queryString = $('#myFormId').formSerialize();

http://malsup.com/jquery/form

或者使用直jQuery的:

Or using straight jquery:

var queryString = $('#myFormId').serialize();

这篇关于我怎样才能得到这将是没有提交所有提交的表单的价值观的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆