/    Sign up×
Community /Pin to ProfileBookmark

Processing HTML strings

[font=trebuchet ms]Hi guys,

I have a PHP-JavaScript communicating script that I’m using to update a page automatically every two seconds. I’d like to avoid as much processing as possible, obviously, so that the application runs more quickly. However, I’ve run into a slight problem. I’m processing URL’s (and some UBB code) on the server (in PHP) and using JavaScript to retrieve the content. I am using the DOM to create a paragraph and new text node to update the page, but when HTML is processed and output by PHP, JavaScript turns up with “undefined.” I know this is because HTML isn’t allowed when creating a text node, but I don’t know how to output the text, the HTML, and any remaining text that PHP might output without having to process the HTML/text altogether as a string in JavaScript. I want to avoid extra processing and I’m trying my best not to use the “innerHTML” attribute. Is there any efficient way to take a string with text and HTML mixed in it and output it as an HTML paragraph with the createTextNode method? (And, of course, without using the “innerHTML” property.)

Thanks,[/font]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@VladdyFeb 26.2005 — Until browsers consistently imlplement DOM Parser, innerHTML remains a way to go:
<i>
</i>if(element.innerHTML)
{ element.innerHTML = XMLString;
}
else
{ /* Write proper implementation in a few years */
}
Copy linkTweet thisAlerts:
@JonaauthorFeb 26.2005 — [font=trebuchet ms]Well, it was worth a try anyway. Thanks, Vladdy![/font]
×

Success!

Help @Jona spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...