0

我正在尝试通过 ajax 获取登录状态,但是 ajax 查询没有正确发生。

function getdetails(playlistname) {
alert(playlistname);
$.ajax({
    type: "POST",
    url: "model/login_details1.php",
    beforeSend: function (xhr) {
        alert("before send");
    },
    error: function (xhr, ajaxOptions, thrownError) {
        alert("ajax error - arun");
        alert(xhr.status);
        alert(thrownError);
    },
    data: {
        fname: name,
        playlistname: playlistname
    }
}).done(function (result) {

    if (!sessionStorage['pid']) {
        sessionStorage['pid'] = result;

    } //    window.location = "Playlist.html";
});
}

我在发布前收到警报,但发布后的警报(错误)消失了。

4

1 回答 1

0

试试下面的 ajax 格式,它可以帮助你快速找出错误。

function getdetails(playlistname) {
    alert(playlistname);
    var name = "" //here is your value.
    $.ajax({
        type: "POST",
        url: "model/login_details1.php",
        data: {
            fname: name,
            playlistname: playlistname
        },
        beforeSend: function (xhr) {
            alert("before send");
        },
        success: function (result) {
            console.log(result); //use this to see the response from serverside
            if (!sessionStorage['pid']) {
                sessionStorage['pid'] = result;
            }
            //  window.location = "Playlist.html";
        },
        error: function (xhr, ajaxOptions, thrownError) {
            alert("ajax error - arun");
            alert(xhr.status);
            alert(thrownError);
        }
    });
}  
于 2013-10-14T06:56:13.670 回答