Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

General Questions /

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

SS 3.0 Admin AJAX response not rendering properly


Reply


8 Posts   1177 Views

Avatar
nedmas

Community Member, 2 Posts

8 September 2012 at 3:01am

Hi,

So I've been using SS 3.0 for a couple of months now, and it's great. Unfortunatly while working on my latest project I've come across a rather odd bug. When using the admin section and loading the main panel via AJAX (for example after publishing a page) the return HTML getting inserted is wrong. All double quotes around tag attributes are rendered with an escaping slash in front e.g. \". Which is prevent the HTML from being rendered correctly. Also all new lines and tabs are quoted as text e.g. "\n\n\t".

I have tried check to see if any files are saved in the wrong format e.g. not UNIX file, but they all seem fine. I have tried replacing the 'cms' and 'framework' with clean copies of both the '3.0' and 'master' branches and still no luck. If anyone could help me get to the bottom of this I would be most grateful!

I have attached a screenshot showing the miss rendered HTML and the AJAX response is bellow. I can provide any other info if required.

{"Content":"<div id=\"pages-controller-cms-content\" class=\"cms-content center cms-tabset CMSPageEditController CMSMain LeftAndMain\" data-layout-type=\"border\" data-pjax-fragment=\"Content\" data-ignore-tab-state=\"true\">\n\n\t<div class=\"cms-content-header north\">\n\t\t<div class=\"cms-content-header-info\">\n\t\t\t<h2>\n\t\t\t\t<div class=\"breadcrumbs-wrapper\" data-pjax-fragment=\"Breadcrumbs\">\n\n\t\n\t\t<span class=\"section-icon icon icon-16 icon-cmspagescontroller\"><\/span>\n\t\n\n\t\n\t\t\n\t\t\t<a class=\"cms-panel-link crumb\" href=\"admin\/pages\/\">Edit Page<\/a>\n\t\t\t<span class=\"sep\">\/<\/span>\n\t\t\n\t\n\t\t\n\t\t\t<span class=\"cms-panel-link crumb last\">New Twitter Page<\/span>\n\t\t\n\t\n<\/div>\n\n\t\t\t<\/h2>\n\t\t<\/div>\n\t\n\t\t<div class=\"cms-content-header-tabs\">\n\t\t\t<ul>\n\t\t\t\t<li class=\"content-treeview ui-tabs-selected\">\n\t\t\t\t\t<a href=\"admin\/pages\/edit\/show\/41\" class=\"cms-panel-link\" title=\"Form_EditForm\" data-href=\"admin\/pages\/edit\/show\/41\">\n\t\t\t\t\t\tContent\n\t\t\t\t\t<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t<li class=\"content-listview\">\n\t\t\t\t\t<a href=\"admin\/pages\/settings\/show\/41\" class=\"cms-panel-link\" title=\"Form_EditForm\" data-href=\"admin\/pages\/settings\/show\/41\">\n\t\t\t\t\t\tSettings\n\t\t\t\t\t<\/a>\n\t\t\t\t<\/li>\n\t\t\t\t<li class=\"content-listview\">\n\t\t\t\t\t<a href=\"admin\/pages\/history\/show\/41\" class=\"cms-panel-link\" title=\"Form_EditForm\" data-href=\"admin\/pages\/history\/show\/41\">\n\t\t\t\t\t\tHistory\n\t\t\t\t\t<\/a>\n\t\t\t\t<\/li>\n\t\t\t<\/ul>\n\t\t<\/div>\n\t<\/div>\n\n\t<div class=\"cms-content-tools west cms-panel cms-panel-layout\" data-expandOnClick=\"true\" data-layout-type=\"border\" id=\"cms-content-tools-CMSMain\">\n\t<div class=\"cms-panel-content center\">\n\t\t<div class=\"cms-content-view cms-tree-view-sidebar cms-panel-deferred\" id=\"cms-content-treeview\" data-url=\"admin\/pages\/treeview\">\n\t\t\t\n\t\t<\/div>\n\t<\/div>\n\t<div class=\"cms-panel-content-collapsed\">\n\t\t<h3 class=\"cms-panel-header\">Your Site Name<\/h3>\n\t<\/div>\n<\/div>\n\n\t<form id=\"Form_EditForm\" action=\"admin\/pages\/edit\/EditForm\" method=\"post\" enctype=\"application\/x-www-form-urlencoded\" class=\"cms-edit-form center CMSPageEditController CMSMain LeftAndMain\" data-pjax-fragment=\"CurrentForm\" data-layout-type=\"border\">\n\n\t<div class=\"cms-content-fields center\">\n\t\t\n\t\t<p id=\"Form_EditForm_error\" class=\"message \" style=\"display: none\"><\/p>\n\t\t\n\n\t\t<fieldset>\n\t\t\t \n\t\t\t\n\t\t\t\t<div id=\"Root\" class=\"ss-tabset tabset\">\n\t<ul>\n\t\n\t\t<li class=\"first \"><a href=\"#Root_Main\" id=\"tab-Root_Main\">Content<\/a><\/li>\n\t\n\t\t<li class=\"last \"><a href=\"#Root_TwitterAccounts\" id=\"tab-Root_TwitterAccounts\">Twitter Accounts<\/a><\/li>\n\t\n\t<\/ul>\n\n\t\n\t\t\n\t\t\t<div id=\"Root_Main\" class=\"tab \">\n\t\t\t\t\n\t\t\t\t\t<div id=\"Title\" class=\"field text\">\n\t<label class=\"left\" for=\"Form_EditForm_Title\">Page name<\/label>\n\t<div class=\"middleColumn\">\n\t\t<input type=\"text\" name=\"Title\" value=\"New Twitter Page\" class=\"text\" id=\"Form_EditForm_Title\" \/>\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\t\t\n\t\t\t\t\t<div id=\"URLSegment\" class=\"field text urlsegment\">\n\t<label class=\"left\" for=\"Form_EditForm_URLSegment\">URL Segment<\/label>\n\t<div class=\"middleColumn\">\n\t\t<span class=\"prefix\">http:\/\/yfc.dev\/<\/span><input type=\"text\" name=\"URLSegment\" value=\"new-twitter-page\" class=\"text urlsegment\" id=\"Form_EditForm_URLSegment\" \/>\n\n<p class=\"help\"> Special characters are automatically converted or removed.<\/p>\n\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\t\t\n\t\t\t\t\t<div id=\"MenuTitle\" class=\"field text\">\n\t<label class=\"left\" for=\"Form_EditForm_MenuTitle\">Navigation label<\/label>\n\t<div class=\"middleColumn\">\n\t\t<input type=\"text\" name=\"MenuTitle\" value=\"New Twitter Page\" class=\"text\" id=\"Form_EditForm_MenuTitle\" \/>\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\t\t\n\t\t\t\t\t<div id=\"Content\" class=\"field htmleditor stacked\">\n\t<label class=\"left\" for=\"Form_EditForm_Content\">Content<\/label>\n\t<div class=\"middleColumn\">\n\t\t<textarea name=\"Content\" value=\"\" class=\"htmleditor stacked\" id=\"Form_EditForm_Content\" rows=\"30\" cols=\"20\" tinymce=\"true\" style=\"width: 97%; height: 480px\"><\/textarea>\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\t\t\n\t\t\t\t\t<div id=\"Form_EditForm_Metadata\" class=\"ss-toggle ss-toggle-start-closed togglecomposite\">\n\t<h4><a href=\"#\">Metadata<\/a><\/h4>\n\t<div>\n\t\t\n\t\t\t<div id=\"MetaTitle\" class=\"field text\">\n\t<label class=\"left\" for=\"Form_EditForm_MetaTitle\">Title<\/label>\n\t<div class=\"middleColumn\">\n\t\t<input type=\"text\" name=\"MetaTitle\" class=\"text\" id=\"Form_EditForm_MetaTitle\" \/>\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\n\t\t\t<div id=\"MetaKeywords\" class=\"field textarea\">\n\t<label class=\"left\" for=\"Form_EditForm_MetaKeywords\">Keywords<\/label>\n\t<div class=\"middleColumn\">\n\t\t<textarea name=\"MetaKeywords\" class=\"textarea\" id=\"Form_EditForm_MetaKeywords\" rows=\"5\" cols=\"20\"><\/textarea>\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\n\t\t\t<div id=\"MetaDescription\" class=\"field textarea\">\n\t<label class=\"left\" for=\"Form_EditForm_MetaDescription\">Description<\/label>\n\t<div class=\"middleColumn\">\n\t\t<textarea name=\"MetaDescription\" class=\"textarea\" id=\"Form_EditForm_MetaDescription\" rows=\"5\" cols=\"20\"><\/textarea>\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\n\t\t\t<div id=\"ExtraMeta\" class=\"field textarea\">\n\t<label class=\"left\" for=\"Form_EditForm_ExtraMeta\">Custom Meta Tags<\/label>\n\t<div class=\"middleColumn\">\n\t\t<textarea name=\"ExtraMeta\" class=\"textarea\" id=\"Form_EditForm_ExtraMeta\" rows=\"5\" cols=\"20\"><\/textarea>\n\t<\/div>\n\t\n\t\n<\/div>\n\t\t\n\t<\/div>\n<\/div>\n\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\n\t\n\t\t\n\t\t\t<div id=\"Root_TwitterAccounts\" class=\"tab \">\n\t\t\t\t\n\t\t\t\t\t<fieldset class=\"grid ss-gridfield ss-gridfield field\" id=\"Form_EditForm_TwitterAccounts\" data-url=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\" data-name=\"TwitterAccounts\"><div class=\"addNewGridFieldButton\">\n\t<div class=\"left\"><a href=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\/item\/new\" class=\"action action-detail ss-ui-action-constructive ss-ui-button ui-button ui-widget ui-state-default ui-corner-all new new-link\" data-icon=\"add\">\nAdd Twitter Account\n<\/a><\/div>\n\t<div class=\"right\"><\/div>\n<\/div>\n<input type=\"hidden\" name=\"TwitterAccounts[GridState]\" value=\"{&quot;GridFieldSortableHeader&quot;:{&quot;SortColumn&quot;:[]},&quot;GridFieldFilterHeader&quot;:{&quot;Columns&quot;:[]},&quot;GridFieldPaginator&quot;:{&quot;currentPage&quot;:1}}\" class=\"gridstate\" id=\"TwitterAccounts-GridState\" \/><table class=\"ss-gridfield-table\" cellpadding=\"0\" cellspacing=\"0\"><thead><tr class=\"title\">\n\t<th colspan=\"2\">\n\t\t<h2>TwitterAccounts<\/h2>\n\t\t<div class=\"right\"><\/div>\n\t\t<div class=\"left\"><\/div>\n\t<\/th>\n<\/tr>\n<tr class=\"sortable-header\">\n\t\n\t\t<th class=\"main col-action_SetOrderScreenName\">\n\t<button name=\"action_gridFieldAlterAction?StateID=504a05ca0b4e58_33406352\" value=\"Screen Name\" class=\"action action ss-gridfield-sort\" id=\"action_SetOrderScreenName\" data-url=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\">\n\t\tScreen Name\n\t<\/button>\n<\/th>\n\t\n\t\t<th class=\"main col-Actions\"><button name=\"showFilter\" class=\"ss-gridfield-button-filter trigger\"><\/button><\/th>\n\t\n<\/tr>\n\n<tr class=\"filter-header\" style=\"display:none;\">\n\t\n\t<th class=\"extra\"><div class=\"fieldgroup nolabel\" >\n\t\n\t\t<div class=\"fieldgroup-field first odd\">\n\t\t\t<div class=\"fieldholder-small\">\n\t\n\t\n\t<input type=\"text\" name=\"filter[ScreenName]\" class=\"text ss-gridfield-sort no-change-track nolabel\" id=\"filter-ScreenName\" placeholder=\"Filter by Screen Name\" \/>\n<\/div>\n\t\t<\/div>\n\t\n\t\t<div class=\"fieldgroup-field last even\">\n\t\t\t<div class=\"fieldholder-small\">\n\t\n\t\n\t\n\t<button name=\"action_gridFieldAlterAction?StateID=504a05ca13ab60_55170741\" class=\"action action ss-gridfield-button-reset nolabel\" id=\"action_reset_TwitterStreamsPage_TwitterAccount_ScreenName\" data-url=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\">\n\t\t\n\t<\/button>\n\n<\/div>\n\t\t<\/div>\n\t\n<\/div><\/th>\n\t\n\t<th class=\"extra\"><div class=\"fieldgroup filter-buttons no-change-track nolabel\" >\n\t\n\t\t<div class=\"fieldgroup-field first odd\">\n\t\t\t<div class=\"fieldholder-small\">\n\t\n\t\n\t\n\t<button name=\"action_gridFieldAlterAction?StateID=504a05ca175fd5_26722503\" class=\"action action ss-gridfield-button-filter nolabel\" id=\"action_filter_TwitterStreamsPage_TwitterAccount_Actions\" data-url=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\">\n\t\t\n\t<\/button>\n\n<\/div>\n\t\t<\/div>\n\t\n\t\t<div class=\"fieldgroup-field last even\">\n\t\t\t<div class=\"fieldholder-small\">\n\t\n\t\n\t\n\t<button name=\"action_gridFieldAlterAction?StateID=504a05ca1a0e39_57650501\" class=\"action action ss-gridfield-button-close nolabel\" id=\"action_reset_TwitterStreamsPage_TwitterAccount_Actions\" data-url=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\">\n\t\t\n\t<\/button>\n\n<\/div>\n\t\t<\/div>\n\t\n<\/div><\/th>\n\t\n<\/tr><\/thead>\n<tfoot><tr>\n\t<td class=\"bottom-all\" colspan=\"2\">\n\t\t\n\t\t\n\t\t<span class=\"pagination-records-number\">\n\t\t\tView\n\t\t\t1 - 2\n\t\t\tof \n\t\t\t2\n\t\t<\/span>\n\t<\/td>\n<\/tr><\/tfoot>\n<tbody class=\"ss-gridfield-items\"><tr class=\"ss-gridfield-item first odd\" data-id=\"1\" data-class=\"TwitterStreamsPage_TwitterAccount\"><td class=\"col-ScreenName\">nedmas<\/td><td class=\"col-buttons\"><a class=\"action action-detail edit-link\" href=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\/item\/1\/edit\" title=\"Edit\">edit<\/a>\n\t<button name=\"action_gridFieldAlterAction?StateID=504a05ca21c304_43729004\" class=\"action action gridfield-button-delete nolabel\" id=\"action_DeleteRecord1\" title=\"Delete\" data-icon=\"cross-circle\" data-url=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\">\n\t\t\n\t<\/button>\n<\/td><\/tr>\n<tr class=\"ss-gridfield-item last even\" data-id=\"2\" data-class=\"TwitterStreamsPage_TwitterAccount\"><td class=\"col-ScreenName\">mrsteveheyes<\/td><td class=\"col-buttons\"><a class=\"action action-detail edit-link\" href=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\/item\/2\/edit\" title=\"Edit\">edit<\/a>\n\t<button name=\"action_gridFieldAlterAction?StateID=504a05ca2468f2_34816132\" class=\"action action gridfield-button-delete nolabel\" id=\"action_DeleteRecord2\" title=\"Delete\" data-icon=\"cross-circle\" data-url=\"admin\/pages\/edit\/EditForm\/field\/TwitterAccounts\">\n\t\t\n\t<\/button>\n<\/td><\/tr><\/tbody><\/table><\/fieldset>\n\t\t\t\t\n\t\t\t<\/div>\n\t\t\n\t\n<\/div>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"ClassName\" value=\"TwitterStreamsPage\" class=\"hidden\" id=\"Form_EditForm_ClassName\" \/>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"ParentID\" value=\"0\" class=\"hidden\" id=\"Form_EditForm_ParentID\" \/>\n\n\t\t\t\n\t\t\t\t<div class=\"cms-navigator\">\n\t<a href=\"#\" class=\"ss-ui-button cms-preview-toggle-link\" data-icon=\"preview\">\n\t\t&laquo; Edit\n\t<\/a>\n\t<ul class=\"cms-preview-states\">\n\t\t\n\t\t\t<li class=\"\"><a href=\"http:\/\/yfc.dev\/new-twitter-page\/?stage=Stage\">Draft Site<\/a>\n\t\t\t\t<span class=\"cms-preview-watermark\">Draft Site<\/span>\n\t\t\t<\/li>\n\t\t\n\t\t\t<li class=\" active\"><a href=\"http:\/\/yfc.dev\/new-twitter-page\/?stage=Live\">Published Site<\/a>\n\t\t\t\t<span class=\"cms-preview-watermark\">Published Site<\/span>\n\t\t\t<\/li>\n\t\t\n\t<\/ul>\n<\/div>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"SecurityID\" value=\"2103026ff3285528342985925b01a74097100427\" class=\"hidden\" id=\"Form_EditForm_SecurityID\" \/>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"ID\" value=\"41\" class=\"hidden nolabel\" id=\"Form_EditForm_ID\" \/>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"AbsoluteLink\" class=\"hidden nolabel\" id=\"Form_EditForm_AbsoluteLink\" \/>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"LiveLink\" value=\"http:\/\/yfc.dev\/new-twitter-page\/?stage=Live\" class=\"hidden\" id=\"Form_EditForm_LiveLink\" \/>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"StageLink\" value=\"http:\/\/yfc.dev\/new-twitter-page\/?stage=Stage\" class=\"hidden\" id=\"Form_EditForm_StageLink\" \/>\n\n\t\t\t\n\t\t\t\t<input type=\"hidden\" name=\"TreeTitle\" value=\"&lt;span class=&quot;jstree-pageicon&quot;&gt;&lt;\/span&gt;&lt;span class=&quot;item&quot;&gt;New Twitter Page&lt;\/span&gt;\" class=\"hidden nolabel\" id=\"Form_EditForm_TreeTitle\" \/>\n\n\t\t\t\n\t\t\t<div class=\"clear\"><!-- --><\/div>\n\t\t<\/fieldset>\n\t<\/div>\n\n\t<div class=\"cms-content-actions south\">\n\t\t\n\t\t<div class=\"Actions\">\n\t\t\t\n\t\t\t\t<fieldset class=\"CompositeField composite ss-ui-buttonset nolabel \">\n\t\n\t\n\t\n\t\t\n\t\t\t\n\t<button name=\"action_unpublish\" value=\"Unpublish\" class=\"action action ss-ui-action-destructive\" id=\"Form_EditForm_action_unpublish\" title=\"Remove this page from the published site\" data-icon=\"unpublish\">\n\t\tUnpublish\n\t<\/button>\n\n\t\t\n\t\n\t\t\n\t\t\t\n\t<button name=\"action_delete\" value=\"Delete from the draft site\" class=\"action action delete ss-ui-action-destructive\" id=\"Form_EditForm_action_delete\" data-icon=\"decline\">\n\t\tDelete from the draft site\n\t<\/button>\n\n\t\t\n\t\n\t\t\n\t\t\t\n\t<button name=\"action_save\" value=\"Save Draft\" class=\"action action\" id=\"Form_EditForm_action_save\" data-icon=\"addpage\">\n\t\tSave Draft\n\t<\/button>\n\n\t\t\n\t\n<\/fieldset>\n\t\t\t\n\t\t\t\t\n\t<button name=\"action_publish\" value=\"Save and Publish\" class=\"action action ss-ui-action-constructive\" id=\"Form_EditForm_action_publish\" data-icon=\"accept\">\n\t\tSave and Publish\n\t<\/button>\n\n\t\t\t\n\t\t\t\n\t\t\t<a href=\"\/new-twitter-page\/?stage=Stage\" class=\"cms-preview-toggle-link ss-ui-button\" data-icon=\"preview\">\n\t\t\t\tPreview &raquo;\n\t\t\t<\/a>\n\t\t\t\n\t\t<\/div>\n\t\t\n\t<\/div>\n<\/form>\n\t\n<\/div>"}

Avatar
n0ne

Community Member, 18 Posts

12 September 2012 at 11:06pm

I had the same problem. I don't know what was the exact problem, but it occured when I changed one db field from Text to HtmlText, but when I saw something weird happend I changed it back again but I didn't helped.
Anyway I solved that problem by removing almost all my files from mysite/code and copied it back.

btw... nedmas what hosting do You use?

Avatar
martimiz

Forum Moderator, 1132 Posts

13 September 2012 at 12:59am

Does this happen on a clean install?

Avatar
n0ne

Community Member, 18 Posts

13 September 2012 at 1:20am

Do You mean fresh install? No I had my site already built with templates, and no additional mdules.

Avatar
martimiz

Forum Moderator, 1132 Posts

13 September 2012 at 1:43am

Yes, I meant fresh, clean, new :-)

It's hard to say if this is a SilverStripe/Server problem, unless you can reproduce it with a fresh install. I've had this happen after I added an echo to my code somewhere (and forgot to remove it). So it might be some output generated 'outside' the panel the AJAX call is reloading - Just guessing...

Avatar
daskode

Community Member, 1 Post

30 July 2013 at 8:29pm

Edited: 31/07/2013 5:01am

I also ran into this issue, and was able to resolve it by removing any extra lines at the top of PHP declarations.

Check all of your php files for an empty line above the <?php declaration. The "<?php" should only start at the first character in the page classes, and controllers.

Since doing this on our site everything appears to be working correctly now.

note:
This could be any page class, or controller from my experience.

Additional symptoms:
This also caused some memory limit exceeded errors on my local dev, that would show up in php logs

Hopefully this helps

/**
* Kody Smith
* Tech Lead @ Clorox Digital
* www.clorox.com
**/

Avatar
PattyOK

Community Member, 5 Posts

31 January 2014 at 8:32am

Was banging my head against a wall on this one for two days!

Extra spacing at the top of the file was totally the culprit!

Thanks!

Avatar
WalterW

Community Member, 18 Posts

2 June 2014 at 8:49pm

I had the same problem and looked for files starting with empty lines before the "<?php" - line.
But this was not my problem, the problem were a .php file in "mysite", containing two empty lines after the closing "?>" line.

After deleting this two lines, the garbage in the edit windows disappeared.