I don't agree....

when I want to pull html out of an ajax response I use : jQuery.xml as I
would use jQuery.html()... if html() actually worked.

$.fn.xml = function () {return $.xml(this[0])}
$.xml = function(xml) { // dump the xml back to html text
   if (!xml) return ""
   var res = ""
   var tag = xml.nodeName
   var showTheTag = tag.charAt(0) != "#"
   if (showTheTag) res += '<' + tag
   if (xml.hasAttributes()) {
       var attrs = xml.attributes
       for (var i = 0; i < attrs.length; i++){
           var attr=attrs[i]
           if (attr.specified) res +=' ' + attr.name + '="' + attr.value +
'"'
       }
   }
   if (showTheTag) res+= ">"
   if (xml.nodeType == 8){
       res += "<!-- " + xml.nodeValue + " -->"
   } else if (xml.nodeValue != null){
       res +=  xml.nodeValue.replace(/\&/g,"&amp;").replace(/\</g,"&lt;")
   }
   if (xml.hasChildNodes()) {
       var children = xml.childNodes
       for (var i = 0; i < children.length; i++){
           var child = children[i]
           res += $.xml(child)
       }
   }
   if (showTheTag)  res += '</' + tag + '>'
   return res
}


On 6/19/07, Benjamin Sterling <[EMAIL PROTECTED]> wrote:

I second Rob's suggestion, this is what I am doing on a few current
projects.

On 6/19/07, RobG <[EMAIL PROTECTED] > wrote:
>
>
>
>
> On Jun 19, 9:46 am, Lovecannon < [EMAIL PROTECTED]> wrote:
> > I use CodeIgniter and jQuery for my frameworks, and i was using the
> > AJAX functions and I tried using XML for a return type, and when id
> > have an error message, it would return a <div> like this format:
> > <response><status>><div class="error">errormsg)</div></status></
> > response>
>
> Put the HTML inside a CDATA section.
>
> <response>
>   <status><![CDATA[<div> ... </div>]]></status>
> </response>
>
>
> Or you could encode the content, but I think CDATA is the way to go.
>
>
> --
> Rob
>
>


--
Benjamin Sterling
http://www.KenzoMedia.com
http://www.KenzoHosting.com




--
Ⓙⓐⓚⓔ - יעקב   ʝǡǩȩ   ᎫᎪᏦᎬ

Reply via email to