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

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -