📜  js 功能 ajax 请求 - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:03:37.357000             🧑  作者: Mango

代码示例1
function checkUserIdExists(userid, callback) {
        return $.ajax({
        url: 'theurl',
        type: 'GET',
        cache: false,
        data: {
           userid: userid
        }
    })
    .done(callback)
    .fail(function(jqXHR, textStatus, errorThrown) {
        // Handle error
    });
}

checkUserIdExists(2, function(data) {
    console.log(data); // Do what you want with the data returned
});