I'd like to save the current content of a codemirror editor using a php script. I used the following codes in the hope when clicking on a button the current content will be passed to the php script. The scripts below has been edited and worked. 

```
var test = code.getValue();

```

but this does not reflect the change in the editor.

```
<script language = "Javascript">
function saveData() {
        var test = editor.getValue();  
    new Ajax.Request('savedata.php', {
    method: 'post',
    parameters: {
        test: test,
        }
    });
}

</script>

```

The editor is constructed using:
 ; 

```
<script>
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
    lineNumbers: true,
    lineWrapping: true,
    extraKeys: {"F11": toggleFullscreenEditing, "Esc": toggleFullscreenEditing},
    onBlur: function(){editor.save()}
});

```

Any comments or suggestions are highly appreciate. Thanks.