2011-07-07 89 views
1

我想從Ajax請求添加加載的HTML Div效果(例如向下滑動)。
我使用這個代碼,但它並沒有影響尚未:將Html添加到Div效果jQuery

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

這可能嗎?

更新:這是我的全碼:

$.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"); 
         } 


        } 
     }); 
+0

看看這個答案http://stackoverflow.com/questions/1520178/jquery-using-append-with-effects –

+0

我寫了我的代碼從這個答案,但不工作。 – Shahin

回答

1

應該努力 - 我認爲「目標文件」是,你可以嘗試它分成兩個只是爲了確保你不有什麼好笑的事情發生。

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

+0

謝謝。我的問題是Div沒有隱藏起來。 – Shahin

1

是的,你可以,但你的對象必須首先隱藏的,所以這樣做:

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

希望這有助於。乾杯