jQuery Get DIV Content From Another Page -
i have following code:
<script> $( document ).ready(function() { $("div.imp-1 span.field-content").each(function() { var $li = $(this); var href = $li.find("a").attr("href") + ".htm"; // use in real case //console.log (href); $.ajax({ type: "post", success: function(data) { var time = $(data).find('.time-default').html(); $li.append(" - " + time); } }); }); }); </script>
the html page has html follows
<div class="time-default">22:15 - 23:30</div>
it keeps returning "undefined" - doing wrong?
thanks
you need pass other page url.
$.ajax({ url: href, //pass url here type: "get", //also use method success: function(data) { var time = $(data).find('.time-default').html(); $li.append(" - " + time); } });
Comments
Post a Comment