博客列表 >2019.5.22作业

2019.5.22作业

关超的博客
关超的博客原创
2019年05月25日 12:51:51691浏览

$.get(), $.post(), $.ajax()小练习


$.get(
            'inc/detail.php',
            {key: $(event.target).val()},   
            function (data,status){     
                console.log(status);
                if (status === 'success') {
                    $('#detail').html(data);   
                    $('[value=""]').remove();  
                } else { 
                    $('#detail').html('<span style="color:red">请求错误</span>');
                }
            },
            'html'
        );
        $.post(
            'inc/check.php',    
            {
                email: email.val(),
                password: password.val()
            },
            function(data) {
                if (data.status === 1) {
                    $('button')     
                        .after('<span style="color: green"></span>')    
                        .next()     
                        .html(data.message) 
                        .fadeOut(2000);    
                } else {
                    $('button')
                        .after('<span style="color: red"></span>')
                        .next()
                        .html(data.message)
                        .fadeOut(2000);
                }
            },
            'json' 
        );
        
        
        $.ajax({
            type: 'POST',
            url: 'inc/check.php',
            data: {
                email: email.val(),
                password: password.val()
            },
            success: function(data) {
                if (data.status === 1) {
                    $('button')     
                        .after('<span style="color: green"></span>')   
                        .next()    
                        .html(data.message) 
                        .fadeOut(2000);    
                } else {
                    $('button')
                        .after('<span style="color: red"></span>')
                        .next()
                        .html(data.message)
                        .fadeOut(2000);
                }
            },
            dataType: 'json'
        })
声明:本文内容转载自脚本之家,由网友自发贡献,版权归原作者所有,如您发现涉嫌抄袭侵权,请联系admin@php.cn 核实处理。
全部评论
文明上网理性发言,请遵守新闻评论服务协议