Sasha Oros schrieb:
> Hi,
> 
> 
> I'm trying to use an ajax post request and not sure why is not working.
> 
> 
> Code in a button:
> 
> $.post(       "HTMLTestPage.htm",
>       {
>              employeeID: "007",
>              requestType: "R"
>       },
>       function(xml){
>               alert( xml );
>               alert( "BankName = " + $("#BankName", xml).val() );             
>                                 
>       }
> );    
> 
> 
> The 'HTMLTestPage.html' is an html page (not xml). When I click on the
> button the first alert returns the whole page and I can see the source code,
> id=BankName and value for the field, but the second alert returns an empty
> string. I tried using the text() and html() function, but the outcome was
> the same.
> 
> By the way, when I created a test button on the 'HTMLTestPage.html' with
> 'alert( $("#BankName" ).val()' it worked and I got the value displayed.
> 
> Any idea?
> 
> 
> Any help is much appreciated, thanks.


In XML an id attribute is not automatically used as the element's id - 
it has to be specified explicitly in a DTD for instance - thus you 
cannot use the '#selector' which will use document.getElementById.

Note from the CSS Spec regarding this:

In XML 1.0 [XML10], the information about which attribute contains an 
element's IDs is contained in a DTD. When parsing XML, UAs do not always 
read the DTD, and thus may not know what the ID of an element is. If a 
style sheet designer knows or suspects that this will be the case, he 
should use normal attribute selectors instead: [name=p371] instead of #p371.
- http://www.w3.org/TR/REC-CSS2/selector.html#id-selectors

There even exists a whole specification of how to handle this:
http://www.w3.org/TR/xml-id/


Long story short: $('[EMAIL PROTECTED]"whatever"]') should work.


-- Klaus


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

Reply via email to