Tinymce is incompatible with jquery ajaxsetup datafilter

I use the following datafilter option on my jquery ajaxsetup:

    dataFilter: function(data)
    {
        var msg;
        if (typeof (JSON) !== 'undefined' &&
        typeof (JSON.parse) === 'function' &&
        data != undefined &&
        data != null &&
        data.length != 0 &&
        data != " ")
            msg = JSON.parse(data);
        else
            msg = eval('(' + data + ')');
        if (msg.hasOwnProperty('d'))
            return msg.d;
        else
            return msg;
    },

When I put this in $.ajaxSetup({,, tinymce is not initialized in my text box (it just shows the original text box as if tinymce is not set). If I move this filter to the actual ajax calls, I have no problems, and everything is fine. Notice that I'm doing everything I can save in a .axx file with ajax support, and it works fine.

jquery 1.4.3, tinymce jquery version 3.3.9.2

Why can the ajaxsetup parameter for a data filter cause tinymce to not work?

+3
source share
1 answer

, TinyMCE , TinyMCE .

function filAjax( settings ) {
  $.ajax(
    $.extend(settings, 
    {
       dataFilter: function(data) {
         var msg;
         if (typeof (JSON) !== 'undefined' &&
         typeof (JSON.parse) === 'function' &&
         data != undefined &&
         data != null &&
         data.length != 0 &&
         data != " ")
             msg = JSON.parse(data);
         else
             msg = eval('(' + data + ')');
         if (msg.hasOwnProperty('d'))
             return msg.d;
         else
             return msg;
         }
    })
  );
}
0

Source: https://habr.com/ru/post/1776455/


All Articles