jquery - Not only wait for page to load but for a content of it to be updated via an ajax call -
i using jquery , ajax remote webpage. if load webpage browser, loads fine, after ~100ms element beingness shown represents counter. counter inserted @ specific place , has specific class. html of place:
<span class="unreadcount">1</span>
i trying create plugin chrome , needs value. thing value not available after page loaded, have wait request page server (for unreadcount number) finish, before processing page's html getting value want.
is there way can jquery? using next code html page:
$.ajax({ async: false, cache: false, type: 'get', datatype: 'html', url: 'https://somesite.com/index.php', success: function(data1) { var descnode = document.createelement("div"); descnode.innerhtml = data1; var unreadcount = descnode.getelementsbyclassname("unreadcount"); /*process unreadcount etc*/ }, error: function () { // went wrong request error_occurred(); return; } });
unfortunately, each time, unreadcount.length 0 , noticed counter wasn't loading along page, shortly after.
how can wait counter load before processing page?
you can't.
you getting webpage string. hence, no javascript executed.
your best bet seek replicate request fetchs unread mail service count. is, if sure done via ajax.
although, using <iframe>
may of help. and, in favor, need <iframe>
solution works in chrome, not cross-browser <iframe>
solution prone fail.
jquery ajax get load
No comments:
Post a Comment