get the ID of the first div in the page loaded via ajax

advertisements

I'm using $.get function for loading partial view:

$.get('/desk/nextstep', function (data) {
            var ids = $(data).filter(':first').attr('id');
            alert(ids);
});

I want to get id of first(root) div, but this code not works:

var ids = $(data).filter(':first').attr('id');

I get undefined alert message. How to solve it?
Thanks.

UPDATE: In the data html code:

<div id="step1" class="scroll-pane">
    <div class="scroll_cont">
     //other content
    </div>
</div>


Try this:

$.get('/desk/nextstep', function (data) {
     var ids = $('<div/>').append(data).find(':first').attr('id');
     alert(ids);
});