AJAX error due to in hidden field – Solution
-
I recently encountered a JavaScript error when submitting cforms forms with AJAX enabled:
javascript
Uncaught TypeError: Cannot read properties of null (reading 'value')As a result, AJAX stopped working and the page reloaded after submission.
In the HTML source, the hidden field
cf_workingwas rendered incorrectly:<input type="hidden" id="cf_workingXX" value="<span>Please wait...</span>„/>Cause:
In thelib_render.phpfile, cforms incorrectly adds a<span>inside thevalueattribute of hidden fields.Solution:
Inlib_render.php, adjust the following line:Before:
value="<span>' . TEXT . '</span>"After:
value="' . TEXT . '"Remove the
<span>from bothcf_workingandcf_failurefields.After this fix, AJAX works properly again.
Note:
This change will be overwritten by future plugin updates.Hope this helps others facing the same issue!
Tested with WordPress 6.x, PHP 8.x, cforms 15.0.7
The topic ‘AJAX error due to in hidden field – Solution’ is closed to new replies.