I can't persuade jQuery to match elements using class selectors on xml
document objects retrieved via $.ajax.

In the following, I run four tests: two expressions with two different
methods of creating xml.  The first method is just to parse a raw string
with jQuery.  The second method obtains the xml through $.ajax.   In both
cases, the XML document is

<?xml version="1.0" encoding="UTF-8"?><doc><foo
class="fooclass"></foo></doc>

The expressions are basic tag selection $('foo') and class selection
$('foo.fooclass').  For each test, I just report the size of the returned
jQuery array.   I'd expect to get four alerts: '1','1','1','1'.  Instead I
get '1','1','1','0', which indicates that for the $.ajax case, the simple
tag selector works, but the class selector does not.  

Any ideas as to what may be the problem?

---------------
var testxml =
'<?xml version="1.0" encoding="UTF-8"?><doc><foo
class="fooclass"></foo></doc>';

function test(expr) {
  alert($(expr, $(testxml)).size());

  $.ajax({
       type: "GET",
       dataType: "xml",
       url: "test.xml",
       success: function(xml) {
         alert($(expr,xml).size());
       }
    });
}

function testboth() {
  test('foo');
  test('foo.fooclass');
}

$(document).ready(testboth);

-- 
View this message in context: 
http://www.nabble.com/class-selector-on-ajax%27d-XML-document-tf2657003.html#a7411291
Sent from the JQuery mailing list archive at Nabble.com.


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to