None
None

Reputation: 5670

Unable to read html from ajax data

I have an ajax call like following

 $("#createnewlist").live('click', function (event) {

    $("#ajax-loading-01").show();
    var createlink = $(this);
    var accountid = createlink.parent().find("input:hidden[name='accountid']").val();
    var listname = createlink.parent().find("input[name='listname']").val();

    //create an ajaxmanager named cacheQueue
    var ajaxManager = $.manageAjax.create('cacheQueue', {
        queue: true,
        cacheResponse: false
    });

    ajaxManager.add(({
        type: 'GET', url: '/ajaxhandler',
        data: { createwishlist: "true", accountid: accountid, listname: listname }

      , success: function (data) {
          alert(data)
          $(".grid03").html($(data).find(".grid03").html());
      }

    }));

});

in success I gets whole data in alert(data) line

  <!-- ActionHandler IS included -->
<p class="favtext">for at folde den ud...</p>
<div class="query-input lynlistesearcher">
  <label>Søg i dine Lynlister</label>
  <input type="text" name="textbox" id="txtesearch" />
</div>
<div class="grid03">
  <ul>  
    <li>
      <div class="head-text">
        <strong data-id="149658491" class="149658491"></strong>
        <a rel="149658491" class="deletelistclass" rev="74123311" href="#">
          <translate key="delete-list">Slet liste</translate>
        </a>
      </div>
    </li>
  </ul>
</div>

but when i try to fetch html from this data

$(data).find(".grid03").html()

It gives null. Can anyone give any clue?

Upvotes: 2

Views: 100

Answers (2)

Perinparajah Prasath
Perinparajah Prasath

Reputation: 41

Try this

$(".grid03").html($(data).eq(2).find(".grid03").html());

Upvotes: 0

Sudhir Bastakoti
Sudhir Bastakoti

Reputation: 100205

try using filter(), so changing:

$(".grid03").html($(data).find(".grid03").html());

to

$(".grid03").html($(data).filter("div.grid03").html());

Upvotes: 1

Related Questions