显示成功ajax的消息

时间:2012-10-15 10:42:43

标签: ajax jquery html

关于jquery ajax请求的成功函数,我必须显示一个div,任何人都可以建议这样做

dataString = "labid="+val;
jQuery.ajax({
type: "POST",
url: "../pim/manageLabelsAdmin",
cache: false,
data: dataString,
dataType: "json",
success: function(data) {
    if(data.success == "yes"){           
        //alert(data.status);
        } else {
            alert("Occured internal Error. please check network connection");
        }
    }
});

2 个答案:

答案 0 :(得分:2)

如果要显示的消息已经在DOM中,但已隐藏,则可以在成功回调中执行以下操作:

if(data.success == "yes")
{            
    $("#id-of-message-element").show();
}

否则,您可以使用.append().prepend().html().text()中的任意一种将消息添加到DOM中,具体取决于您的需求。

有关DOM插入方法的更多信息:

http://api.jquery.com/category/manipulation/dom-insertion-inside/

答案 1 :(得分:0)

如果你的div有id,那么这个

$('#yourDivId').show();

否则,如果您的fiv有班级

$('.yourDivClassName').show();
相关问题