Save Return Error in Sitecore Page Editor

痴心易碎 提交于 2019-12-05 10:06:22

This is being caused by a confirmed bug in Sitecore. (reference # 84051 when opening a ticket)

You can resolve this yourself, but I still recommend going through Sitecore so they can ensure that you have what you need.

To solve, look at the /sitecore/shell/client/Sitecore/ExperienceEditor/ExperienceEditor.js file, on line 510 you will see that decodeURIComponent is being called twice.

Updating it to only be called once like data: decodeURIComponent(JSON.stringify(commandContext)) will resolve the error.

Likewise, a change is required in the /sitecore/shell/client/Sitecore/ExperienceEditor/RibbonPageCode.js file on line 24.

Here, adding the decodeURIComponent method call is what fixes this file. So like this: ribbonUrl: decodeURIComponent(this.PageEditBar.get("url")),

This probably addresses the Coveo issue as well, but my clients are not currently using Coveo, so I can't verify that.

This post fixed for me. Note I'm using Sitecore 8.2 Update 2

My error:

After parsing a value an unexpected character was encountered: {. Path 'scLayout', line 1, position 2246.

http://jockstothecore.com/experience-editor-error/

postServerRequest: function (requestType, commandContext, handler, async) {

    function normalizeDeviceProp(d) {
        if (typeof(d) !== "object")
            throw new Error("Unexpected presentation details XML: cannot find device property");

        if (d instanceof Array)
            return d;

        var normalized = [];
        normalized.push(d);
        return normalized;
    }

    var token = $('input[name="__RequestVerificationToken"]').val();

    // Custom Brainjocks code to fix Experience Editor error.
    var ajaxData = unescape(JSON.stringify(commandContext));
    if (commandContext && commandContext.scLayout) {
        var obj = JSON.parse(commandContext.scLayout);
      if (obj && obj.r) {
          normalizeDeviceProp(obj.r.d).forEach(function (d) {
              if (d.r instanceof Array) {
                  d.r.forEach(function (r) {
                      var val = r["@par"];
                        if (val && val.length > 0) {
                            ajaxData = ajaxData.replace(unescape(val), val);
                        }
                  });
              }

            });
        }
    }

    jQuery.ajax({
        url: "/-/speak/request/v1/expeditor/" + requestType,
        data: {
            __RequestVerificationToken: token,
            data: ajaxData
        },
        success: handler,
        type: "POST",
        async: async != undefined ? async : false
    });
}

Check the content of all of the fields being saved. The Experience/Page editor has to serialize everything into a json object to call its own internal API's. There might be a stray character in one of your fields tripping up the json serializer. I ran into this when the content editor had copy and pasted their content from elsewhere.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!