Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/231.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery/PHP更新后显示数据库_Php_Jquery - Fatal编程技术网

Jquery/PHP更新后显示数据库

Jquery/PHP更新后显示数据库,php,jquery,Php,Jquery,我有一个jQuery,它在blur上更新DB。它工作正常,除了我希望代码在更新后显示当前的DB值。数据库中有一个值,该字段中的金额将被添加到该值中并得到更新。现在唯一能看到这一点的方法是在每次更新某些内容时刷新页面 <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script> <scr

我有一个jQuery,它在blur上更新DB。它工作正常,除了我希望代码在更新后显示当前的DB值。数据库中有一个值,该字段中的金额将被添加到该值中并得到更新。现在唯一能看到这一点的方法是在每次更新某些内容时刷新页面

        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.2/jquery.min.js"></script>
    <script type="text/javascript">
    // JQUERY: Plugin "autoSumbit"
    (function($) {
        $.fn.autoSubmit = function(options) {
            return $.each(this, function() {
                // VARIABLES: Input-specific
                var input = $(this);
                var column = input.attr('name');

                // VARIABLES: Form-specific
                var form = input.parents('form');
                var method = form.attr('method');
                var action = form.attr('action');

                // VARIABLES: Where to update in database
                var where_val = form.find('#where').val();
                var where_col = form.find('#where').attr('name');

                // ONBLUR: Dynamic value send through Ajax
                input.bind('blur', function(event) {
                    // Get latest value
                    var value = input.val();
                    // AJAX: Send values
                    $.ajax({
                        url: action,
                        type: method,
                        data: {
                            val: value,
                            col: column,
                            w_col: where_col,
                            w_val: where_val
                        },
                        cache: false,
                        timeout: 10000,
                        success: function(data) {
                            // Alert if update failed
                            if (data) {
                                document.getElementById("notice").innerHTML="Error, NO UPDATE";
                            }
                            // Load output into a P
                            else {
                                $('#notice').text('Updated');
                                $('#notice').fadeOut().fadeIn();
                            }
                        }
                    });
                    // Prevent normal submission of form
                    return false;
                })
            });
        }
    })(jQuery);
    // JQUERY: Run .autoSubmit() on all INPUT fields within form
    $(function(){
        $('#ajax-form INPUT').autoSubmit();
    });
    </script>
HTML内容


PHP文件将行插入数据库后,让它从数据库中选择新值,并在对jQuery的AJAX响应中回显该值。然后使用jQuery将新值填充到您希望它去的任何地方。

我键入了几乎完全相同的内容:
            <label>Total:</label>
            <input name="company" value="<?php echo $row['total'] ?>" />

        <label>Tax-in:</label>
            <input name="lastname" value="<?php echo $row['taxin'] ?>" />