Jquery - parsing the results returned from webmethod

I have a jquery that executes a stored proc and returns all the teams a user is a member of and also it returns the teams that have the search term a user entered.  

Here is my jquery

$(document).ready(function(){  
  $('div.TUButton').click(function() {
    var searchingfor = $('#searchterm').val()
 
       
    $.ajax({
    type: "POST",
    url: "/CMSPages/WebService.asmx/TeamUpSearchResults",
    data: JSON.stringify({ searchterm: searchingfor}),
    contentType: "application/json",
    success: function (data) {
      // Do something on sucess
    },
   
    error: function(jqXHR, status, errorThrown) {
      // Do something on failure
    }
  });
 
});
});

here is a sample of what gets returned

<string><div class="groupID" data-groupname="HumanResources">
    <div class="teammember" data-teammember="True">
    </div>
    </div>
</string>

The UI  has a setup like the attached.  In this example I would want to parse out the data-groupname where data-teammember = True and put a checkbox next to the group.  

Can someone help me with how to parse this inside my jquery.

Thanks in advance

hr.jpg
sherbug1015Asked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MlandaTCommented:
It is not easier to request JSON data back by passing in a dataType: "json" along with the call to the web service? That said, you can parse the XML using jQuery in this way:
<script>
var xml = "<string><div class='groupID' data-groupname='HumanResources'><div class='teammember' data-teammember='True'></div></div></string>";

var xmlDoc = $.parseXML( xml );
var $xml = $( xmlDoc );
var $div = $xml.find( "div" );

var groupname = $($div[0]).attr("data-groupname");
var teammember = $($div[1]).attr("data-teammember");
</script>

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.