How to wait for data loading after the load function? small example:

$("#hideitem").load(link); alert($("#hideitem").html()); // здесь пока пусто, нужно подождать. как это сделать? 

  • one
    read the documentation?) api.jquery.com/load (callback fuction) - ThisMan
  • one
    Will you give a link to the canonical answer on the asynchronous or will it be a mockery? :) - Pavel Mayorov
  • @ThisMan link is like no answer, especially on English and for RuNet - perfect
  • @perfect, I designed as an answer? I left a comment, and besides, it’s better not to intervene in English without programming - ThisMan
  • @perfect then here in Russian jquery.page2page.ru/index.php5/… : D - Alexey Shimansky

1 answer 1

Once you have found the load method, you could see that it looks like this:

 .load(url,[data],[callback],[dataType]): 

and that he can write a callback function as the third parameter, which will be called after the html-text sent by the server is placed on the selected page elements. Sobssn it and you need to write and use.

Example:

 $("#result").load( "ajax/test.php", { param1: "param1", param2: 2 }, function(){alert("Получен ответ от сервера.")} ); 
  • thank. worthy answer instead of holivar - perfect
  • @perfect actually hints that you need to take a closer look at some of the features that you use. Maybe sometimes (often) you don’t know everything and need to check it - Alexey Shimansky
  • it's different. Why when I google in English then for any bunch I get to English SO where there is an answer with a bunch of pluses ... are they stupid? how do you think? ... or inattentive? - perfect
  • @perfect if you don’t even add the word Stackoverflow to the search field, then everything’s okay to google: D ......... so I’ve got jquery load s018.radikal.ru/i518/1702/78/1a071a061d9c.jpg JQuery docks in English, in Russian and in W3S ¯ \ _ (ツ) _ / ¯ - Alexey Shimansky
  • and you tried to google jquery load wait and see where you go ... - perfect