XML responses from my webapp have both HTML to add to the page AND some have a script to run.
I'm trying to send back XML from my webapp like:
<?xml version="1.0"?>
<doc>
<html-to-insert>
<![CDATA[<p>add me to the page</p>]]>
</html-to-insert>
<script>
<![CDATA[ alert('execute me'); ]]>
</script>
</doc>
What I'm doing now is snapping out the <html-to-insert>
and <script>
CDATA, inserting the html into the page and eval'ing <script>
.
I'm looking for criticism on my approach. Any suggestions from anyone?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…