Question

Hi I am using jQuery Ajax to "GET" "XML" data,
and am trying to "append" the data as a "Template".

And I am trying to append the Title:

   <div class="btn-group" style="margin:5px">
      <img class="img-swap2" data-toggle="dropdown" src="images/drop-down-btn_2.png">
     <a href="#">Title</a>
    </div>

append the Image/Description:

<img src="images/toggle-on.png" class="img-swap"/>
<a class="pull-left" href="#"></a>
   <div class="media-body" style>
       <div class="media">
          <a class="pull-left" href="#">                
             <img class="media-object" src="images/Penguins.jpg"></a>
           <div class="media-body">
             <textarea class="form-control" rows="4" readonly>Description..</textarea>
           </div>
       </div>
   </div>

Append Code:

var html = title + thumbnailUrl + description

var title = $(cur).find("title").text();
var thumbnailUrl = $(cur).find("thumbnailUrl").text();
var description = $(cur).find("description").text();

var $l = $mainStoryList;
$l.append(html);
Was it helpful?

Solution

title,description,thumbnailUrl are class selectors means speacify with dot(.) like this

var title = $(cur).find(".title").text();
var thumbnailUrl = $(cur).find(".thumbnailUrl").text();
var description = $(cur).find(".description").text();

Suppose it is all are id selector means put # before on it

var title = $(cur).find("#title").text();
var thumbnailUrl = $(cur).find("#thumbnailUrl").text();
var description = $(cur).find("#description").text();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top