Update TinyMCE with json
HTML
<script src="http://www.tinymce.com/js/tinymce/jscripts/tiny_mce/tiny_mce_jquery.js"></script>
<button id="calljson">Call conente from server</button>
<hr />
<textarea id="content" name="content">
<p>Old text</p>
</textarea>
CSS
a {
pointer: default;
}
JavaScript
tinyMCE.init({
mode: "textarea"
});
$(function() {
$("#calljson").bind("click", function() {
var ed = tinyMCE.get('content');
ed.setProgressState(1); // Show progress
$.ajax({
url: '/echo/json/',
delay: 4,
data: {
json: "{'content': '<h1>New header</h1><p>new content</p>'}"
},
dataType: 'json',
success: function(data) {
ed.setProgressState(0); // Hide progress
ed.setContent(data.content);
},
error: function() {
alert("error");
}
});
});
});