【问题标题】:JQuery and AJAX $.post() functionJQuery 和 AJAX $.post() 函数
【发布时间】:2013-10-04 12:16:52
【问题描述】:

我的一位大学教授帮助我创建了这个函数。它通过将#txtNewPassword 字段的值解析为“checkpasslength.php”文件来检查密码的长度,该文件处理数据并根据$.post() 中数据的长度/内容返回一个值。 ...我不明白的唯一部分是 $.post() 函数的第二个参数... reg.password.value 究竟做了什么?我几乎知道它的作用(在每次按键时发送表单中的值),但是 .reg 是什么意思?

$(document).ready(function() {
    $('#checkPassLength').load('checkpasslength.php').show();

    $('#txtNewPassword').keyup(function() {
        $.post('checkpasslength.php', {password: reg.password.value}, 
        function(result) {
            $('#checkPassLength').html(result).show();
        });
    });
});

【问题讨论】:

  • reg..的值是多少???
  • reg 来自哪里??
  • keyup 方法中使用console.log(reg) 并找出自己!

标签: jquery ajax http-post


【解决方案1】:

第二个参数 {password: reg.password.value} 是实际的密码值。 reg.password.value 表示 form_name.field_name.value。

【讨论】:

    猜你喜欢
    • 2011-12-11
    • 1970-01-01
    • 2013-03-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-09-21
    • 1970-01-01
    • 2012-11-05
    相关资源
    最近更新 更多