phpjqueryhtmlajaxjquery-bootgrid

Bootgrid - Unexpected token < in JSON at position 0


I am having a bootgrid table which I populate using ajax, the problem is when I select multiple columns from db, after ten columns I receive an error. Does anyone know if boodgrid has a limitation or something. I specify that the data are ok, I tested all of them with less than eleven rows and it works perfectly, but if I select more than 10 columns from db I receive this:

Uncaught SyntaxError: Unexpected token < in JSON at position 0 at JSON.parse ()
at Function.m.parseJSON (VM217 jquery-1.11.3.js:5)
at Object.success (VM219 jquery.bootgrid.js:231)
at j (VM217 jquery-1.11.3.js:2)
at Object.fireWith [as resolveWith] (VM217 jquery-1.11.3.js:2)
at x (VM217 jquery-1.11.3.js:5)
at XMLHttpRequest.b (VM217 jquery-1.11.3.js:5)


Solution

  • Your request doesnt return JSON, but (highly likely) HTML and the HTML starts with <!DOCTYPE or <html>, either starts with your unexpected <. It tries to parse the HTML as a JSON-string, can't, and errors.

    If you open your browsers console, go to the tab where you can see the requests made (e.g.'Network'), select the one with the error and see what you actually get returned. There will be an error there or other information to push you in the right direction.