After a number of very frustrating hours, I have discovered very painfully that errors that occur in Ajax just stop it from working without reporting an error. Shared so that you might not have the same pain…
A shortened version of what caused this:
Problem:
On onClick event a field {pay} was supposed to update after a calculation, using Ajax and an internal library function. The field would not update. No error was displayed.
Trying to test this:
{pay} = 27;
would update in the Ajax event and show 27
$a = 27;
{pay} = $a;
would just leave the {pay} field blank!
Cause:
There was an error in the function (in this case trying to address a non-existent element in an array).
This still permitted a number of things to work downstream of the error to report on the array or assigned variables e.g.
echo
var_dump()
which was very confusing. It just would not then assign any variables to the fields.
I’m not sure how the best way of troubleshooting this is - mine was painstakingly slow, line by line - but any ideas to be shared about spotting errors in Ajax would be widely appreciated I’m sure.