On a clean install try to install the "Testing Sample Data"
Sample data completes all 8 steps successfully
Sample data "hangs" after step 7 and console shows the following error
VM701:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
at JSON.parse (<anonymous>)
at onSuccess (sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1)
at XMLHttpRequest.c.onreadystatechange (core.min.js?988a0f8a06606e444ef81cacee8fef3d:1)
onSuccess @ sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1
c.onreadystatechange @ core.min.js?988a0f8a06606e444ef81cacee8fef3d:1
XMLHttpRequest.send (async)
a.request @ core.min.js?988a0f8a06606e444ef81cacee8fef3d:1
c.sampledataAjax @ sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1
onSuccess @ sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1
c.onreadystatechange @ core.min.js?988a0f8a06606e444ef81cacee8fef3d:1
XMLHttpRequest.send (async)
a.request @ core.min.js?988a0f8a06606e444ef81cacee8fef3d:1
c.sampledataAjax @ sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1
onSuccess @ sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1
c.onreadystatechange @ core.min.js?988a0f8a06606e444ef81cacee8fef3d:1
XMLHttpRequest.send (async)
a.request @ core.min.js?988a0f8a06606e444ef81cacee8fef3d:1
c.sampledataAjax @ sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1
onSuccess @ sampledata-process.min.js?988a0f8a06606e444ef81cacee8fef3d:1
c.onreadystatechange @ core.min.js?988a0f8a06606e444ef81cacee8fef3d:1
Labels |
Added:
?
|
Labels |
Added:
J4 Issue
|
Multilingual sample data works.
Status | New | ⇒ | Discussion |
VM701:1 Uncaught SyntaxError: Unexpected token < in JSON at position 0
It’s obvious that the response is not json, probably because of a php error. A try/catch on the parsing will eliminate the console error (and should be done) but also the root of the problem should be fixed (eg php side)
Dimitri is right. The source is most likely a PHP error. You should see it in the log file.
It may only be a notice, which when displayed may break the JSON response. XDebug also doesn't help here with its HTML output :)
On the JS things I can't help but it certainly should somehow catch such errors and give an appropriate generic message (eg "malformed response" or along that line).
PHP Notice: Undefined property: Joomla\CMS\Table\Module::$element in /home/richard/lamp/public_html/joomla-cms-4.0-dev/plugins/system/httpheaders/httpheaders.php on line 201
A lot of them come when installing testing sample data. I think the same also came when installing blog sample data before. Interesting that it did not come with multilanguage sample data.
But there were no PHP errors, only these notices.
Disabling the httpheaders plugin resolves the problem :(
Title |
|
And who can care for the js part?
dgrammatiko:
A try/catch on the parsing will eliminate the console error (and should be done)
Bakual:
On the JS things I can't help but it certainly should somehow catch such errors and give an appropriate generic message (eg "malformed response" or along that line).
@richard67 the change is really simple follow my comment on #23936 (comment)
basically, the onSuccess needs to look like this:
onSuccess: (resp) => {
let responnse;
try {
response = JSON.parse(resp);
} catch (error) {
throw new Error('Failed to parse JSON')
}
Also this patch needs to be applied to all the ajaxy scripts that deal with json responses!!!
Disabling the httpheaders plugin resolves the problem :(
Please check and share the browser console message when this error happens (from chrome when possible).
Please also tell us which headers you have enabled and with what settings.
Thanks.
PHP Notice: Undefined property: Joomla\CMS\Table\Module::$element in /home/richard/lamp/public_html/joomla-cms-4.0-dev/plugins/system/httpheaders/httpheaders.php on line 201
A lot of them come when installing testing sample data. I think the same also came when installing blog sample data before. Interesting that it did not come with multilanguage sample data.
@richard67 that error message should have nothing to-do with sample data hopefully. As this line should only be executed when we have an onExtensionAfterSave. But please share a dump of the event object ($event) just before the error comes up. Or can you reproduce the error message?
Please check and share the browser console message when this error happens (from chrome when possible).
Already in the first post
Please also tell us which headers you have enabled and with what settings.
Clean install so whatever the defaults are
Already in the first post
That is the only message?
Clean install so whatever the defaults are
The only defaults on a clean install are x-frame-options
, xss-protection
, referrer-policy
, (x-content-type-options
).
Where I don't expect issues from x-frame-options
and referrer-policy
.
x-content-type-options
is now enforced from the htaccess file so the setting has no affect.
So the only thing could be xss-protection
can you try to disable that instead of completly disable the plugin?
Status | Discussion | ⇒ | Closed |
Closed_Date | 0000-00-00 00:00:00 | ⇒ | 2019-07-29 11:30:09 |
Closed_By | ⇒ | franz-wohlkoenig |
You never fixed the client side problem here so why was this closed?
Blog sample data stops after step 2 of 4 with