开发者

Check the content in ajax call

Is it possbile to check whether the content is loaded fully in the ajax call made and after that show some div. Till the content is not loaded fully the div should not shown and after th开发者_JAVA百科e content is come then the div has to be shown using jquery?


the answer is based on total assumptions, also define an error callback

$.ajax({
  url: "/path/to/server",
  type: 'POST',
  data: data,
  success: function(data){    <-- the success is called upon successful completion    
    //do something with data
   $("#divID").html(data);
   $("#divID").show();  <-- assumed the div was hidden initially
  },
  error:function(jxhr){
   if(typeof(console)!='undefined'){
    console.log(jxhr.status+"--"+jxhr.responseText);
   }
 }
});


Use jQuery ajax call success callback. It will fires only after finishing the request:

$.ajax({
   type: "GET",
   url: "some.html",
   success: function(data){
     // show my div here
     $('#mydivid').html(data).show();
   }
 });
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜