Unexpected token < in JSON at position 0

Re: Unexpected token < in JSON at position 0

by Blair F. -
Number of replies: 3
Picture of Particularly helpful Moodlers

We're also getting the error message, but the message still goes through.

We just upgraded from 3.2 to 3.4, which included having to change a lot of links from http: to https: and we're still finding glitches all over the place. I'm not sure if there's any connection here.

In reply to Blair F.

Re: Unexpected token < in JSON at position 0

by Blair F. -
Picture of Particularly helpful Moodlers

I'm just updating my post of August 7th, after a little more trial and error. What happens is this:

1) Send a message to someone

- SyntaxError appears

2) Close the error popup.

- The message eventually appears in the sent messages window

3) Without changing or refreshing the screen, try sending another message to the same user.

- Nothing happens - message won't send.

4) Refresh your screen, using F5

5) Try sending a message, again.

- SyntaxError appears

In other words, even though you get an error message, you can send ONE message, successfully. After that, you must refresh the screen in order to send another.

Strangely enough, and just to make matters more complicated and mysterious, shortly after I tested all of that the entire issue disappeared. But then it reappeared again, this morning! Ugh. I'm baffled.

In reply to Blair F.

Re: Unexpected token < in JSON at position 0

by Blair F. -
Picture of Particularly helpful Moodlers

Update: The problem seemed to be gone for about an hour, this morning, but then returned. How the heck do you troubleshoot something like this? Argh!

Here's what I get with debugging on:

SyntaxError: Unexpected token < in JSON at position 0
    at parse (<anonymous>)
    at Qb (https://ourmoodle.ca/lib/javascript.php/1535731337/lib/jquery/jquery-3.2.1.min.js:1:74283)
    at A (https://ourmoodle.ca/lib/javascript.php/1535731337/lib/jquery/jquery-3.2.1.min.js:1:77810)
    at XMLHttpRequest.<anonymous> (https://ourmoodle.ca/lib/javascript.php/1535731337/lib/jquery/jquery-3.2.1.min.js:1:80414)

In reply to Blair F.

Re: Unexpected token < in JSON at position 0

by Matteo Scaramuccia -
Picture of Core developers Picture of Peer reviewers Picture of Plugin developers

Hi Blair,
please open the Network pane of the Developer Tools and explore each request looking at its response: an AJAX call (xhr) would show you an HTML payload instead of a JSON one and in that HTML you'll read what your Moodle instance is complain about, preventing to output the expected JSON response.

Edit: are you talking here about https://moodle.org/mod/forum/discuss.php?d=374445 ?

HTH,
Matteo