我正在尝试通过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";
});
}
我在发布前收到提醒,但发布后的提醒(错误)正在消失。
答案 0 :(得分: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);
}
});
}