Bug Tracker

Opened 7 years ago

Closed 7 years ago

#12126 closed bug (invalid)

jquery html from xml

Reported by: puchuu Owned by: puchuu
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.2
Keywords: Cc:
Blocked by: Blocking:

Description

http://stackoverflow.com/questions/11609028/jquery-html-from-xml

For dmethvin: do not close issue if you dont understand it. you can contact with me for any extra information

Change History (8)

comment:1 Changed 7 years ago by puchuu

this is coffee script code that works perfect:

$.ajax
  type:     "get"
  url:      @options.load_url
  dataType: "xml"
  success: (data) =>
    @preload.empty()
    if $.browser.msie
      if $.browser.version == "7.0" or $.browser.version == "8.0"
        @preload.append $(data.xml).filter(".scene")
      else
        @preload.append $(data.xml).find(".scene")
    else
      @preload.append $(data).find(".scene")

    html = @preload.html()
    @preload.empty().html html
Last edited 7 years ago by puchuu (previous) (diff)

comment:2 Changed 7 years ago by dmethvin

Owner: set to puchuu
Status: newpending

You're right, I have no idea what you are trying to do. You're trying to append XML nodes to an HTML document? Can you provide a clear example in plain JavaScript?

comment:3 Changed 7 years ago by puchuu

Status: pendingnew

ok. I will paste link to jsfiddle here in 5-10 minutes

comment:5 Changed 7 years ago by puchuu

for dmethvin: I've newer used bugtracker to ask questions. I've posted a workaround on stackoverflow and than created an issue to share my experience with jquery developers

comment:6 Changed 7 years ago by dmethvin

$(data).find("section").html()

You're trying to call .html() on XML nodes. Is that correct? The documentation for .html() is pretty clear it isn't available on XML documents. http://api.jquery.com/html/

I've newer used bugtracker to ask questions.

That is not what a bug tracker is for, so you were correct in using StackOverflow.

comment:7 in reply to:  6 Changed 7 years ago by puchuu

Replying to dmethvin:

You're trying to call .html() on XML nodes

I want: get html from xml without using CDATA + .text(). This is possible in theory because this xml is valid html. This is possible with jquery only with workaround that I've posted

comment:8 Changed 7 years ago by dmethvin

Resolution: invalid
Status: newclosed

The text markup string may be valid HTML5, but the in-memory data structures are XML nodes and not HTML nodes. As the documentation says, the .html() method is not available on XML documents. oldIE will not easily import XML nodes into an HTML document. Also, oldIE doesn't support HTML5 so you'll need a shiv/shim which I assume you already have. But none of this is a bug and as far as I can tell things as working as documented.

Perhaps this will help explain the issues: http://www.alistapart.com/articles/crossbrowserscripting/

Note: See TracTickets for help on using tickets.