jq的post和get

129 阅读1分钟

post方法

    $.post(url, {
        username: $("input[type=text]").val(),
        password: $("input[type=password]").val()
    }, function (res) {
        if (res.meta.status != 200) {
            alert(res.meta.msg)
            return
        }
    })

get方法

    $.get('a.json', {
        username: $("input[type=text]").val(),
        password: $("input[type=password]").val()
    }, function (res) {
        if (res.meta.status != 200) {
            alert(res.meta.msg)
            return
        }
    })

post和get区别在于post请求不会将数据泄露出来安全性更高一些。