I've created a web part which displays a list of Teamsites (site collections) to which a user has access.
It works
perfectly in Chrome and Firefox.

In IE(7&8), the
.finds fail every time, returning only "" instead of the text values that are there.
I've been at this a while and don't know what I'm missing.
If anyone can supply the mathemagical, metamystical incantations, I will be most appreciative!!!
Here's the code:
<script type="text/javascript" src="https://demo-team.gsk.com/_layouts/jquery/jquery-1.4.2.js"></script><script type="text/javascript" src="https://demo-team.gsk.com/_layouts/jquery/jquery.SPServices-0.5.6.js"></script><script type="text/javascript">var queryXml = '<QueryPacket xmlns="urn:Microsoft.Search.Query">' + '<Query domain="QDomain">' + '<SupportedFormats><Format>urn:Microsoft.Search.Response.Document:Document</Format></SupportedFormats>' + '<Context>' + '<QueryText type="MSSQLFT" language="en-US">' + 'SELECT title, path FROM Scope() WHERE (ContentClass = \'STS_Site\') AND path LIKE \'https://demo-team%\' ORDER BY title' + '</QueryText>' + '</Context>' + '<Range><StartAt>1</StartAt><Count>50</Count></Range>' + '</Query>' + '</QueryPacket>';xmlDocToString = function(xmlDoc) { var xstr = ""; if (typeof DOMParser != "undefined") { // Chrome, Firefox, Mozilla - real browsers xstr = (new XMLSerializer()).serializeToString(xmlDoc); } else if (typeof ActiveXObject != "undefined") { // Internet Explorer - ?? xstr = xmlDoc.xml; } return xstr;} $(document).ready(function(){ populateLinks = function(names, hrefs) { var count = names.length; if (count == 0) { $("#MemberMsg").html("You are not a member of any GSK Teamsites."); } else if (count <= 6) { if (count == 1) { $("#MemberMsg").html("You are a member of one GSK Teamsite."); } else { $("#MemberMsg").html("You are a member of " + count + " GSK Teamsites."); } for (var i=0; i<count; i++) { var link = '<a href="' + hrefs[i] + '">' + names[i] + '</a>'; $("#LeftList").append('<li style="line-height:20px;">' + link + '</li>'); } $("#LinksList").show(); } else { $("#MemberMsg").html("You are a member of " + count + " GSK Teamsites."); var half = Math.round(count/2); for (var i=0; i<half; i++) { var link = '<a href="' + hrefs[i] + '">' + names[i] + '</a>'; $("#LeftList").append('<li style="line-height:20px;">' + link + '</li>'); if (i+half < count) { link = '<a href="' + hrefs[i+half] + '">' + names[i+half] + '</a>'; $("#RightList").append('<li style="line-height:20px;">' + link + '</li>'); } } $("#LinksList").show(); } } scrubXML = function (xmlString) { var xs = xmlString.replace(/</g, "<").replace(/>/g, ">"); var b = xs.indexOf("<ResponsePacket"); var e = xs.indexOf("</ResponsePacket"); xs2 = xs.substring(b, e+17); xs = xs2.replace(/ xmlns="[a-z,A-Z,:,\.]+"/g, ""); return xs; } $().SPServices({ operation: "Query", async: false, queryXml: queryXml, debug: true, webURL: "https://demo-team.gsk.com", completefunc: function (xData, Status) { //var out = $().SPServices.SPDebugXMLHttpResult({ // node: xData.responseXML, indent: 4 // }); //$("#WSDump2").html("").append("<strong>This is the output from the SPServices.Query() operation:</strong>" + "<br/><br/>" + out + "<br/><br/>"); //$("#WSDump2").append("<strong>Debug output:</strong><br/><br/>"); var xmlString = xmlDocToString(xData.responseXML.documentElement); //$("#WSDump2").append("xmlString=" + xmlString + "<br/><br/>"); var xmlString2 = scrubXML(xmlString); //$("#WSDump2").append("xmlString=" + xmlString2 + "<br/><br/>"); var count = $(xmlString2).find("Count").text(); //$("#WSDump2").append("Count=" + count + "<br/>"); var titles = new Array(count); var paths = new Array(count); var cnt = 0; $(xmlString2).find("Properties").each(function () { titles[cnt] = $(this).children(":first").find("Value").text(); paths[cnt] = $(this).children(":last").find("Value").text(); cnt++; }); populateLinks(titles, paths); } });});</script> <div id="WSDump2"></div><table border="0"> <tr style="height:5px;"/> <tr> <td id="MemberMsg" style="text-align:center;"></td> </tr> <tr style="height:10px;"/> <tr> <td> <div id="LinksList" style="display:none"> <table style="border:1px solid #bcaaa7;" cellspacing="10px"> <tr> <td style="vertical-align:top;"><ul id="LeftList" style="list-style-type:square;color:#a88a86;margin-right:0px;"></ul></td> <td style="vertical-align:top;"><ul id="RightList" style="list-style-type:square;color:#a88a86;margin-right:5px;"></ul></td> </tr> </table> </div> </td> </tr></table>Additional questions are:
- Is there an easier way (assume I don't know what I'm doing!)
- Why do I have to work so hard to remove namespaces; everything coming back from a SQL query is going to be full of them
Cheers and Thanks!
S~