Add Html to Div with effect jQuery

為{幸葍}努か 提交于 2019-12-08 07:53:24

问题


I want to add Loaded html from Ajax request to Div with effect (for example slide down).
I am using this code but it doesn't have effect yet :

obj.html(msg.d).show('slow');

Is it possible ?

Update : this my full code:

 $.ajax({
            type: "POST",
            url: options.webServiceName + "/" + options.renderUCMethod,
            data: options.ucMethodJsonParams,
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            cache: true,
            success:
                    function (msg) {
                       var html = msg.d;
                        obj.html(msg.d).show('slow');



                        // if specified make callback and pass element
                        if (options.completeHandler)
                            options.completeHandler(this);
                    },
            error:
                    function (XMLHttpRequest, textStatus, errorThrown) {
                        if (options.errorHandler) {
                            options.errorHandler(this);
                        } else {


                            obj.html("error");
                        }


                    }
        });

回答1:


Should work -- I assume that "obj" is a , you can try to split it up into two just to make sure you don't have anything funny going on.

$(obj).html(msg.d); $(obj).show(500); // 500 ms animation time




回答2:


Yes, you can, but your object must be hidden initially, so do:

obj.hide().html(msg.d).show('slow');

Hope this helps. Cheers



来源:https://stackoverflow.com/questions/6606029/add-html-to-div-with-effect-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!