[solved]SyntaxError: Unexpected token < in JSON at position 0

merlino68

Member
when I change the data of a list with the relative form, I receive the error in question.
The form opens in Ajax popup.
No problem if i disable Ajax for link
I try to update from github but it does not solve the problem
Joomla 3.9.3
Fabrik 3.9
php 7

Thanks
 
Check the response in the network tab of your browser console.
This is usually a notice/warning/error breaking the expected JSON response.
 
this is the error report
Uncaught TypeError: Cannot read property 'findClassUp' of null
at eval (eval at runLoadEvent (media/com_fabrik/js/element.js:206), <anonymous>:1:53)
at Object.runLoadEvent (media/com_fabrik/js/element.js:206)
at Object.e.extend.$owner (mootools-core.js:38)
at Object.addNewEvent (media/com_fabrik/js/element.js:254)
at Object.e.extend.$owner (mootools-core.js:38)
at Object.dispatchEvent (media/com_fabrik/js/form.js:966)
at Object.e.extend.$owner (mootools-core.js:38)
at eval (eval at <anonymous> (jquery.min.js:2), <anonymous>:101:14)
at Object.execCb (eval at <anonymous> (jquery.min.js:2), <anonymous>:29:311)
at $.check (eval at <anonymous> (jquery.min.js:2), <anonymous>:18:423)
 
Do you have a JS event on one of your elements, running on 'load'?

If so, and it includes the use of the findClassUp() method, you need to debug it, and figure out why the selector you are doing a findClassUp() on is null.

Also, if you are using findClassUp(), best to replace it with something like jQuery's closest(), like ...

Code:
var mything = jQuery('.mySelector').closest('someOtherSelector');

-- hugh
 
I dont have a JS on load , i have this in calc element:

$db =& JFactory::getDBO();
$query = "SELECT COUNT(DISTINCT`Sezione`) from tm_schede where id_allen={tm_allenamenti___id}";
$db->setQuery($query);
return $db->loadResult();
 
Are you sure?

The error being thrown is definitely in our runLoadEvents() method, where it evaluates Javascript code for element JS events set to run on 'load'.

Can you check all the elements on the form in the popup, have a look at the Javascript section for each element, make sure none of them have a 'load' event set up.

-- hugh
 
There is only one element with JS but even if unpublished the form it makes the same error
I think the problem is in the calc element.
When the element is unpublished, the form works.
When the element is published, I have the error when I save.
I solved by changing the calc element in the field element and doing the calculation in another list.

-- hugh
 
OK.

BTW, the issue with your query in that calc is probably twofold:

First, you always need to quote placeholder values, so the query doesn't error out if the element is empty, and second you probably need to use the _raw (if it's a join element).

Code:
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select('COUNT(DISTINCT `Sezione`) as tot')->from('tm_schede')->where('id_allen=' . $db->quote('{tm_allenamenti___id}'));
$db->setQuery($query);
return $db->loadResult();
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top