如何从javascript刷新php中的值?

时间:2014-03-25 19:12:25

标签: javascript php variables

我有一个表单,我使用javascript提交。但是,其中一项检查使用了一个查询API并获取用户密码的php脚本。这是用于表单验证的目的(即,如果密码与我们在文件中的内容不匹配..)

我使用php脚本解码密码,如此

function submitForm() {

    var options = {
        decoded_password: '<?php echo abc_decode($contactInfo['Password'])?>',
    }

    if (jQuery('#current_password').val() != options.decoded_password &&  $psc('#current_password').val()) {
        render_alert('Your current password does not match what we have on file.');
        return false;

    } else {
        $psc('#account-information').submit();
        document.getElementById("account-information").reset();
    }

页面加载,很棒,提交表单,很棒。但是,从第一页加载中记住变量,因此如果我再次尝试更改密码,则表示我的密码与文件中的密码不匹配。如果我重新加载页面,没问题。

有没有办法在没有页面重新加载的情况下更改javascript中$contactInfo['Password']的值?

1 个答案:

答案 0 :(得分:1)

您可以尝试进行AJAX调用。这不需要重新加载页面,但仍然可以让您将数据发送回服务器。如果将数据存储在$ _SESSION变量中,它将在多个调用中保持不变。