error on image upload- Cannot read property 'id' of undefined
error on image upload- Cannot read property 'id' of undefined
I have a editor instance to add members to a table which is working fine.
I have just added an image upload option to the editor, (1.5.3) and if i try to add an image, I get an error Uncaught TypeError: Cannot read property 'id' of undefined. - dataTables.editor.js:3811
I tried copying the upload code snippet from a working page, and cant seem to fix it.
Probably something silly, but would appreciate another pair of eyes
http://www.test.forthwebsolutions.com/admin/members/plugins/members.php
This question has an accepted answers - jump to answer
Answers
The response from the upload command is not the JSON that Editor expects. It looks like an edit response:
Whereas it should be something like:
This example might be of some use.
Allan
Please indulge me by looking at this page, which works, and I believe has the same json
http://test.forthwebsolutions.com/admin/content/plugins/events.php
If I upload a file it responds with something like:
from the upload request. That looks correct and valid to me.
Allan
Thanks Allan.
Seeing the problem, and being able to work out WHY it was causing me an error took me all day to track down, but I finally found out the problem.
when i call the editor instance, if I use
the upload works fine
if i use the syntax
i get the error message as described
What version of Editor are you using? The second should work well in the latest versions.
Thanks,
Allan
Hi Allan, I am using 1.5.3
I can upload a comparative sample if it helps
original code, (fails) link as above
http://www.test.forthwebsolutions.com/admin/members/plugins/members.php
new code (works)
http://www.test.forthwebsolutions.com/admin/members/plugins/members2.php
(it is only a problem with upload, if the record is edited without changing the upload data, it works fine)
Got it! Thanks for the clarification. The fix will be included in Editor 1.5.5, but in the mean time if you want to apply the fix locally, in Editor search for:
and replace with:
The issue was that the original Ajax object was being modified rather than a new object being created.
Regards,
Allan