You may want to consider looking into using jXs:
http://www.malsup.com/jquery/jxs/

The problem is XML doesn't work like HTML when inserted into the DOM, even
though it looks like HTML. I hacked up some code from jXs to convert the XML
into HTML and made it a little plugin called htmlify. I use it like this:

$.get('/ajax/foo', params, function(data) {
   if($('success', data).size() > 0) {
       $('#result').prepend($('success', data).children().htmlify());
   } else {
       ...
   }
});

The returned XML looks like:
<success><div class="foo"><span>Some stuff</span></div></success>


The plugin is just hacked up stuff from jXs:

jQuery.fn.htmlify = function() {
   if(this.size() == 1) {
       return jQuery(makeElement(this.get(0)));
   } else {
       var htmlifyNodes = [];
       this.each(function() {
           var temp = makeElement(this);
           htmlifyNodes.push(temp);
       });
       return jQuery(htmlifyNodes);
   }

   function makeElement(xmlNode) {
       switch(xmlNode.nodeType) {
           case 1:  // element
               return element(xmlNode);
           case 3:  // text
           case 4:  // cdata -- Corrected by Mike Alsup 07/26/2006
               var t = xmlNode.nodeValue.replace(/^\s+|\s+$/g, " "); //
condense white space
               return t.length < 1 ? undefined : document.createTextNode
(t);
           default:
               return undefined; // do nothing;
       }
       function element(xNode) {
           var node = document.createElement(xNode.tagName);
           for(var i = 0, a = xNode.attributes; i < a.length; i++) {
               jQuery(node).attr(a[i].nodeName, a[i].nodeValue);
           }
           for(var i = 0, c = xNode.childNodes; i < c.length; i++) {
               var child = makeElement(c[i]);
               if(child) {
                   node.appendChild(child);
               }
           }
           if(node.metaDone) {
               node.metaDone = undefined;
           }
           return node;
       }
   }
};

It probably totally breaks on IE. I haven't tried it yet.

--Erik

On 12/13/06, Johnny <[EMAIL PROTECTED]> wrote:


hi,guys

i get a form in table by jquery.

if the form like this:

<table>
<form>
<tbody>....<tbody>
</form>
</table>

The table does not display in firefox(i use ff2.0), but it's ok in IE.
and i can find the table of dom from DOM inspector add-on,  it does
exists!!

i try some lots of ways to find what happened. And last i find.

if html like this:
<form><table><tbody>....<tbody></table> </form>

it can display in ff2.

note: it just happens when you get html in ajax, but it's okay
accessing directly by ff2

I'm sorry my poor English:)
Johnny



Johnny wrote:
>
> Hi, guys
>
> I have a problem when i use jquery's ajax module.
>
> My jquery code is here:
>
> $(document).ready(function() {
>       $("div#test").load("xml_to_page.jsp",{"class":"Img","sn":"1"});
>  });
>
> xml_to_page.jsp is file transform xml to html
>
>  String xml = "\\xml\\" + class + ".xml";
>  String xsl =  "\\xml\\item_attr_form.xsl";
>     try {
>         XSLTHelper.transform(xml, xsl, out);
>     } catch ( Exception e ) {
>         e.printStackTrace(response.getWriter());
>     }
>
> it works in IE, it can display html created by the xml_to_page.jsp , but

> it doesn't display in FireFox, and i use DOM Inspect, the div#test
> actually have content.
>
> So where is the problem?
>
> Thank you advance!
>
> Johnny
>

--
View this message in context:
http://www.nabble.com/Is-it-a-bug-tf2805700.html#a7848698
Sent from the JQuery mailing list archive at Nabble.com.


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

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

Reply via email to