Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic

Re: [OT?] formatting response text for AJAX widget

by jfluhmann (Scribe)
on Aug 04, 2006 at 15:35 UTC ( #565732=note: print w/replies, xml ) Need Help??

in reply to [OT?] formatting response text for AJAX widget

What about trying a different approach using JSON:
print qq{ {"componentId": "$componentId", "html": "<a href='#' onClick='javascript:makeForm( \"$componentId\", +\"$componentType\", \"$newTitle\");'>$newTitle</a>"} };
Inside your JavaScript, use:
jsonText = eval( '(' request.responseText ')' ); $('override_' + jsonText.componentId).innerHTML = jsonText.html;

Replies are listed 'Best First'.
Re^2: [OT?] formatting response text for AJAX widget
by geektron (Curate) on Aug 04, 2006 at 15:46 UTC
    I haven't read up enough on JSON to use it, so for now, the nasty extra escapes will have to do.

    Regardless, thanks for the suggestion.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://565732]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2020-02-21 17:07 GMT
Find Nodes?
    Voting Booth?
    What numbers are you going to focus on primarily in 2020?

    Results (96 votes). Check out past polls.