Jacob van Lingen
Jacob van Lingen

Reputation: 9567

CKEditor 4.3.4 - Response script is not evaluated

I am trying to make uploading possible for CKEditor. I added the uploadUrl in my config:

config.filebrowserUploadUrl = cfData.jsService+'?method=uploadImage';

In my backend I use Coldfusion to upload the image, and create the the return script:

<cffunction name="uploadImage" access="remote" output="false" returntype="string" returnformat="plain">
    <cfargument name="upload" required="true">
    <cfargument name="CKEditorFuncNum" type="numeric" requited="false">

    ... // image upload logic

    <cfreturn "<script type=""text/javascript"">window.parent.CKEDITOR.tools.callFunction("& arguments.CKEditorFuncNum &", '[dynamic-image-url]', '');</script>">
</cffunction>

The response tab in Chrome shows the following:

<script type="text/javascript">window.parent.CKEDITOR.tools.callFunction(1, '[dynamic-image-url]', '');</script>

Everything seems to go well, but then the code is printed as string in the DOM, instead as HTML: enter image description here

Is there something I am doing wrong? I know it's not the version, as CKFinder also uses 4.3.4 and it works for them (http://cksource.com/ckfinder/demo#ckeditor).

N.B. When I evaluate the callFunction by running it in the console, the image is shown in the image-popup.

Upvotes: 1

Views: 655

Answers (1)

Jacob van Lingen
Jacob van Lingen

Reputation: 9567

Found it just after typing this question, small mistake... I gave the wrong content-type header (text/plain).

Fixing that in CF is quite easy:

cfcontent type="text/html">

Upvotes: 2

Related Questions