The HTML code in my array is being appended as
<a href=\"../u/ldgbug\">Sam Sangs</a> has updated her location.
When I want the actual html included on the page. Any idea how I can fix this?
I am using this to generate it...
[syntax=javascript]news_text[i].appendChild(document.createTextNode(feed[0][i]['message']));[/syntax]
My encoded array outputs...
<a href=\"..\/u\/somebug\">Sam Sangs<\/a> has updated her location.
And this php is what generates that array value...
[syntax=php]$data[0][$k]['message'] = '<a href="../u/' .$r['feedusername']. '">' .ucwords($r['feedfirstname'].' '.$r['feedlastname']). '</a> has updated ' .($r['gender'] == 1 ? 'his': 'her');[/syntax]
JSON Encoded HTML Fails
Re: JSON Encoded HTML Fails
That's what createTextNode does ![Confused :?](./images/smilies/icon_e_confused.gif)
If you are sending html code via JSON, you are using JSON wrong.
You should send the data only and have JavaScript create the layout.
Also, please make sure you post in the correct sections.
![Confused :?](./images/smilies/icon_e_confused.gif)
If you are sending html code via JSON, you are using JSON wrong.
You should send the data only and have JavaScript create the layout.
Also, please make sure you post in the correct sections.
-
- Posts: 165
- Joined: Fri May 06, 2011 5:02 pm
Re: JSON Encoded HTML Fails
jacek wrote:That's what createTextNode does
If you are sending html code via JSON, you are using JSON wrong.
You should send the data only and have JavaScript create the layout.
Hmm ok well that's good to know. I'll just have JS create everything.
jacek wrote:please make sure you post in the correct sections.
Whoops. Sorry. My mind is traveling a mile a minute.