아약스 안에 div 태그를 삽입하려고하는데 어떻게 그럴 수 없습니까? 지금까지이 코드가 내 코드입니다 :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) {
}
});
}
시도했지만 작동하지 않습니다 ... 어떤 생각입니까?
감사합니다.
당신은 당신의 페이지에 아이디 login_invalid와 사업부를해야합니까? –
console.log (is_logged), 결과를 알 수 있습니다. 편집 : 당신은 이미 jquery를 사용하고 있으므로 $ ("# login_invalid") .html ("Invalid"); getElementById를 사용하는 것이 아닙니다. – KBN
[기본 DOM 조작 튜토리얼 찾기] (https://www.google.nl/search?q=dom+manipulation+tutorial+-jquery) – Cerbrus