我试图在 ajax 中插入一个 div 标签,但我不知道如何。到目前为止,这是我的代码:
function userLogin(){
var email = $("#login_username_text").val();
var password = $("#login_password_text").val();
var login_url = connect_url+'retrieveUser.php?email='+email+"&password="+password;
$.ajax({
type: 'GET',
url: login_url,
async: true,
jsonpCallback: 'userCallback',
contentType: "application/json",
dataType: 'jsonp',
success: function(json) {
is_logged = (json[0].logged==0)?false:true;
alert(is_logged);
alert(email);
alert(password);
if(is_logged==false){
alert ("Invalid Username and Password"); //I want to change
//this into a div tag so that it will be displayed on the page itself and so that
//I can add CSS codes here
}
},
error: function(e) {
}
});
}
我试过document.getElementById('login_invalid').innerText = 'Invalid Username and Password.';
但没有工作......有什么想法吗?
谢谢!