开发者

insert a href in a ajax message return. (code included)

$return['error'] = false;
$return['msg'] = 'You have been logged in! You will be redirected to the UserCP in  3 seconds! If redirection fails <a href="usercp.php">click here</a>';

Is being returned but the <a href is being displayed as text and not a link.

Relevent snippet of a开发者_开发技巧jax code:

$.ajax({
            type : 'POST',
            url : 'logina.php',
            dataType : 'json',
            data: {
                type : $('#typeof').val(),
                login : $('#login').val(),
                pass : $('#pass').val(),


            },
            success : function(data){
                $('#waiting').hide(500);
                $('#empty').show(500);
                $('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
                    .text(data.msg).show(500)
                    if (data.error === true){
                    $('#reg').show(500);ß
                    $('#empty').hide();
                }
                else {
                setTimeout(function(){ document.location = 'http://blahblah.com/usercp.php';}, 3000 ); 

                    }


Use .html rather than .text:

$('#message').removeClass().addClass((data.error === true) ? 'error' : 'success')
                    .html(data.msg).show(500)
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜