I am currently using Javascript + AJAX to request and return the data from a CKeditor instance to a PDF renderer. I need to change this to JQuery + AJAX. I am working in a GSP in Grails 2.4.3.
Here's my working Javascript:
function getCK(){
return CKEDITOR.instances.thisInstance.getData();
}
function upDate(){
var xhr = new XMLHttpRequest();
xhr.open("POST", "https://someURL/app/someController/someAction", false);
xhr.onreadystatechange = function () {
if (xhr.status === 200 && xhr.readyState === 4) {
document.getElementById("pdf").setAttribute("data", xhr.responseText);
}
};
xhr.send(getCK());
}
upDate();
The code above works, but my employer wants JQuery.
Here's what I have so far that doesn't work:
function upDate(){
$.ajax('${createLink(controller:'someController', action:'someAction')}',{
type:'POST',
data: CKEDITOR.instances.thisInstance.getData();
},
success: function (data) {
$('#pdf').attr('data', data);
},
error: function(jqXHR, textStatus){ alert(jqXHR.responseText);}
});
}
upDate();
Not sure why this isn't working, this exact code works throughout our gigantic application numerous times.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire