Save a Query

You can add your custom save action to the save button in the Query Builder. You could for example use the callback function connected to the button to submit the JCSDL using a POST request or another AJAX request to:

  • Trigger an automatic compilation through the DataSift API.
  • Store the state of the Query Builder in a database.
  • Output the JCSDL query in a text field.

The following examples show respectively how you can retrieve the JCSDL code in a text type HTML element and how you can submit JCSDL through a POST request.

<title>JCSDL Editor | Save query example</title>
<meta http-equiv="content-type" content="text/html; charset=utf-8">

<script type="text/javascript" src=""></script>

<link rel="stylesheet" type="text/css" href="jcsdl/jcsdl.min.css" />
<script type="text/javascript" src="jcsdl/jcsdl.definition.js"></script>
<script type="text/javascript" src="jcsdl/jcsdl.min.js"></script>


<div id="jcsdl"></div>

<textarea name="jcsdl-output"> </textarea>

<script type="text/javascript">
var editor = new JCSDLGui('#jcsdl', {

    save : function( code ) {
        // output the resulting JCSDL code into a textarea
        $('textarea[name="jcsdl-output"]').val( code );