我正在使用此处
现在我有一个表单,其中用户名& 密码
Now i have a form with username & password
我的要求是将密码字段的值更改为其 md5 ,为此,我使用的是此处
My requirement is to change the value of password field to its md5 so for that I am using the plugin found here
为此,我正在这样使用:
so for that I am using like this :
$('myForm').ajaxForm({ url : 'pathtosend', type : 'post', beforeSubmit : function(arr, $form, options){ $('#password').val($.md5($('#password').val())); }, success : function(response, statusText, xhr, $form){ alert('blah blah'); } });现在,当我在 java servlet代码中打印 password 的值时,它显示的是我传递的值,而不是我的值的md5.
Now when I print the value of password in java servlet code it shows the one that I passed and not the md5 of the value as I did.
当我将编码更改为单击 submit 按钮并操纵提交完成时,我的问题是,当数据更改时 beforeSubmit 的意义是什么?不会提交
When I changed the coding to the click of the submit button and manipulating the submit its done so my question is what is the significance of beforeSubmit when the data changed is not going to reflect in the submit
推荐答案您需要将beforeSubmit函数更改为此:
You need to change your beforeSubmit function to this:
beforeSubmit : function(arr, $form, options){ arr.push({name:'hashed-password', value:$.md5($('#password').val())}) },然后,您可以在servlet中访问hashed-password变量.
Then you can access the hashed-password variable in your servlet.
这样做的原因是来自文本输入的值已经由AjaxForm处理并存储在arr数组中.
The reason for this is that the value from the text input has already been processed by AjaxForm and stored in the arr array.
如果您不想发送纯文本密码,则可以使用原始方法,但可以将beforeSubmit : function(arr, $form, options){更改为beforeSerialize : function() {
if you don't want to send the plaintext password, you can use your original method but change beforeSubmit : function(arr, $form, options){ to beforeSerialize : function() {
更多推荐
提交前更改数据
发布评论