Days
Hours
Minutes
Seconds
x

Froala Editor v4.2.0 is Here LEARN MORE

Skip to content

Save Concepts

Autosave

The save pluging plugin has built-in mechanisms that automatically make HTTP requests from JS to your server, which has to handle the requests and save the data. You need to handle these requests on the server side and store the data.

Save options

You can use the following options and events to customize the autosave action:

saveIntervalSets the editor to automatically make save requests after a specified time.
saveParamTells the editor in which parameter of the request to put the edited content. By default it is set into the body param.
saveURLThe URL where the save request is being made.
saveMethod specifies the HTTP request type for the save action.
saveParams option can be used to pass additional parameters in the request.
froalaEditor.save.before event is triggered before the save request and it can be used to set additional save params or cancel the save action.
froalaEditor.save.after event is triggered after a successfully save request.
froalaEditor.save.error event is triggered if any error occurs during the upload process.

Initialize the WYSIWYG HTML editor

<div id="myEditor"></div>

<script>
  new FroalaEditor('#myEditor', {
    // Change save interval (time in miliseconds).
    saveInterval: 2500,

    // Set the save param.
    saveParam: 'content',

    // Set the save URL.
    saveURL: 'http://example.com/save',

    // HTTP request type.
    saveMethod: 'POST',

    // Additional save params.
    saveParams: {id: 'my_editor'},

    events: {
      'save.before': function () {
        // Before save request is made.
      },

      'save.after': function () {
        // After successfully save request.
      },

      'save.error': function () {
        // Do something here.
      }
    }
  })
</script>

Receive request on the server

If the saveInterval option is set to a value grater than 0, HTTP requests are made automatically after each specified interval. The content will be sent in the content parameter of the request and the server has to process the request and save the data in the DB. If any additional saveParams are passed they will also be included in the request.

PHP example: For the code above you would get the rich text editor's content in $_POST['content'] variable and the additional information in $_POST['id'].

Do you think we can improve this article? Let us know.