'Unexpected token < in JSON at position 0' when enrolling users manually

Re: 'Unexpected token < in JSON at position 0' when enrolling users manually

by Marcos A -
Number of replies: 0
You're right, I was getting the "fall-back" enrolment page. I noticed the absence of the pop-up that I was used to, but since it worked, I was happy and I didn't pay too much attention to it.

Weirdest thing about it is that I hadn't logged in my Moodle since your last message and now it suddenly was broken again despite $CFG->cachejs = false;. Not sure why, maybe JavaScript was being initialized faster.

Regarding Mario's workaround, maybe it was a cache thing or that I was adding the Content-Type command to a wrong line in the code. Long story short, I just added header('Content-Type:application/json'); to service.php and the pop-up is showing. Seems perfect now.

Enrol users pop-up

Thanks so much, it's quite fascinating to learn about why this sort of things fail.