如何在Ajax中添加DIV标签

I'm trying to insert a div tag inside ajax but I just can't figure out how. So far this is my code:

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) {

        }
}); 
}

I tried document.getElementById('login_invalid').innerText = 'Invalid Username and Password.'; but not working... any idea?

Thanks!

innerText isn't an universally supported property. And while the more standardized textContent is useful to read the content it's better to use innerHTML to replace the content of a div.

Assuming your div exists, you should use

document.getElementById('login_invalid').innerHTML = 'Invalid Username and Password.';

or, as you obviously use jQuery

$('#login_invalid').html('Invalid Username and Password.');

Try

$("<div/>", {
    "class": "test",
    text: "Invalid Username and Password",
    }).appendTo("body");

You can append the div tag and add class to it, it will work. If you want to add Id to this element you can use .attr('attribute_name','attribute_value') as follow:

if(is_logged==false){
      $('body').append('<div>Invalid Username and Password</div>').addClass("error").attr('id', 'login_invalid');
 }