Editor screen wont close or open again

Editor screen wont close or open again

M1408M1408 Posts: 28Questions: 8Answers: 1

All changes made in the editor are being updated using the AJAX call. The AJAX success function is being implemented (I have an alert when success). The only thing is the editor screen does not close. If I click outside the screen it will close but I can't open any other screen unless I reload the entire page.

I am sending a few different arrays and constants. The first is an array with the data being modified and a number that represent the key in the datatbase. This is also the array that I am echo at the end of the AJAX call (echo json_encode($EdittedFieldArray))

tableEditor = new jQuery.fn.dataTable.Editor( 
            {
                ajax:  function()
                {
                    jQuery.ajax(
                    {   
                        type: 'POST',
                        url:  '/wp-content/AJAX/EditorSubmit.php',
                        dataType: 'json',
                        data: {'AJAX_Data2Submit':DataToSubmit,'AJAX_groupid':GIDField, 'AJAX_TFT': TFTSubmitArray, 'AJAX_TCT': TCTSubmitArray, 'AJAX_NewLDates':NewLArray, 'AJAX_MaxTFT': NewMaxTFT, 'AJAX_MaxTCT': NewMaxTCT, 'AJAX_MaxJN': NewMaxJN},
                        success: function(d)
                        {
                            alert('Entry was successfully modified');
                        },
                        error: function (xhr, error, thrown)
                        {
                                    alert('Error'); 
                        }
                    });
                    },
                table: '#LogTable',
                idSrc:  24,     
            });

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 63,161Questions: 1Answers: 10,406 Site admin
    Answer ✓

    Hi,

    When you override the built in Ajax call that Editor makes by providing your own function to the ajax option you must call either the success or error callbacks that are passed into the function. Otherwise Editor can't know that the request is complete.

    In your code above you don't have any of the arguments being passed into the function shown - update it to be ajax: function ( method, url, data, success, error ).

    Allan

  • M1408M1408 Posts: 28Questions: 8Answers: 1

    Hi Allan,

    Thanks, that worked. I do have a follow up and newbie question though. I create the success and error functions but they are not being called. The editor screen is closing and the edit is taking effect, but the success and error functions are not called

    tableEditor = new jQuery.fn.dataTable.Editor(
                {
                    ajax:  function()
                    {
                        jQuery.ajax(
                        {  
                            type: 'POST',
                            url:  '/wp-content/AJAX/EditorSubmit.php',
                            dataType: 'json',
                            data: {'AJAX_Data2Submit':DataToSubmit,'AJAX_groupid':GIDField, 'AJAX_TFT': TFTSubmitArray, 'AJAX_TCT': TCTSubmitArray, 'AJAX_NewLDates':NewLArray, 'AJAX_MaxTFT': NewMaxTFT, 'AJAX_MaxTCT': NewMaxTCT, 'AJAX_MaxJN': NewMaxJN},
                            success: function(d)
                            {
                                success(d); 
                            },
                            error: function (xhr, error, thrown)
                            {
                                 error(xhr,error,thrown);
                            }
                        });
                        },
                    table: '#LogTable',
                    idSrc:  24,    
                });
    OTHER CODE GOES HERE
           
    
        function success(data)
        {
            alert('Entry was modified successfully');
        }
        function error(x,b,c)
        {
            alert('XHR:' +  xhr + ' - ERROR: '+error + ' - Thrown: '+ thrown );
        }
    
    
    
  • M1408M1408 Posts: 28Questions: 8Answers: 1
    edited May 2017

    Never mind, I figured it out. My function declaration was wrong

    Thanks for your help Allan!

        var Success = function(data)
        {
            alert('Entry was modified successfully');
        }
        var Error = function(x,b,c)
        {
            alert('XHR:' +  xhr + ' - ERROR: '+error + ' - Thrown: '+ thrown );
        }   
    
  • ThereanTherean Posts: 1Questions: 0Answers: 0

    Allan thank you very much, I just found the answer here to my question. lots of thanks.

This discussion has been closed.