Unescape HTML entities in Javascript?

前端 未结 30 3040
野趣味
野趣味 2020-11-21 05:40

I have some Javascript code that communicates with an XML-RPC backend. The XML-RPC returns strings of the form:


30条回答
  •  时光取名叫无心
    2020-11-21 06:07

    Not a direct response to your question, but wouldn't it be better for your RPC to return some structure (be it XML or JSON or whatever) with those image data (urls in your example) inside that structure?

    Then you could just parse it in your javascript and build the using javascript itself.

    The structure you recieve from RPC could look like:

    {"img" : ["myimage.jpg", "myimage2.jpg"]}
    

    I think it's better this way, as injecting a code that comes from external source into your page doesn't look very secure. Imaging someone hijacking your XML-RPC script and putting something you wouldn't want in there (even some javascript...)

提交回复
热议问题