http://www.perlmonks.org?node_id=565732


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;