旧值来自Jquery模态框POST


Old values coming in POST from Jquery Modal Box

所以我搞乱了非常愚蠢的问题,有一个正常的HTML形式,我在模态框中打开更新值。当我更改任何文本框的值并单击Ajax调用按钮时,有旧值进入POST而不是更改值

例如,如果有值5,我将其更改为10并触发Ajax,但在POST数据中仍然有5。我使用on获取当前值。

这是我的HTML代码的一部分:

<form action="" id="UpdateBind_data">
   <input type="text" id="weightage" name="weightage" value="<?php echo $mapping_data->weightage; ?>">
<button type="button" class="btn btn-primary UpdateBind">Update</button>
</form>
Jquery:

 $("body").on("click", ".UpdateBind", function() {
        var Datastring = $("#UpdateBind_data").serialize();// Retrive the old values not the changed ones.
        $.ajax({
            type: "POST",
            url: updatedbindlink,
            data: Datastring,
            datatype: "json",
            cache: false,
            success: function(response) {
                if(response.res)
                {
                    alert("Mapping data successfully Inserted");
                }
                else
                {
                    //error
                }
                return false;
            }
        });
    });

也许是因为表单在执行JQuery绑定之前提交?试试这个:

 $("body").on("click", ".UpdateBind", function(e) {
        e.preventDefault();
        var Datastring = $("#UpdateBind_data").serialize();// Retrive the old values not the changed ones.
        $.ajax({
            type: "POST",
            url: updatedbindlink,
            data: Datastring,
            datatype: "json",
            cache: false,
            success: function(response) {
                if(response.res)
                {
                    alert("Mapping data successfully Inserted");
                }
                else
                {
                    //error
                }
                return false;
            }
        });
    });