首页 > 代码库 > AjAX请求后台,无刷新更新页面

AjAX请求后台,无刷新更新页面

$(function () {
        $(‘#按钮ID‘).click(function () {

            $.ajax({
                url: ‘请求地址‘,
                data: ‘传递参数‘,
                datatype: ‘text/plain‘,//请求类型
                success: function (返回参数) {
                    if (result == "1") {
                        返回后处理数据
                    }
                },
                error: function () { }
            });

        });
    });

例------------------------

前台点击btnting‘按钮,请求数据到后台,更新数据库后,根据返回结果刷新页面

$(function () {
        $(‘#btnting‘).click(function () {

            $.ajax({
                url: ‘Delectjinzhi‘,
                data: ‘type=0‘,
                datatype: ‘text/plain‘,
                success: function (result) {
                    debugger
                    if (result == "1") {
                        $(‘#selkstime‘).attr("disabled", false); //启用控件使用
                        $(‘#seljstime‘).attr("disabled", false); //启用控件使用
                        $(‘#btnkai‘).attr("disabled", false); //禁止启用按钮
                        $(‘#btnting‘).attr("disabled", true); //启用停止按钮
                        $(‘[name="checkweek"]‘).each(function () {
                            $(this).attr("disabled", false);
                        });
                    }
                },
                error: function () { }
            });

        });
    });

AjAX请求后台,无刷新更新页面