Hi Theo,
Can you tell me a bit more about what you are experiencing by way of failure? The AJAX related JS has an error handler so if the server sends an error code, something should happen.
It sounds as though perhaps there is a network issue or something the is stopping execution of the JavaScript. When this happens, are there any exceptions in the browser console? Additionally, are there any errors on the server?
Is there possible a site set up that reproduces the issue so that I can take a look?
Cheers,
Phil
Hi Phil,
I noticed this when there was a PHP fatal error in one of my project’s files:
PHP Fatal error: Uncaught TypeError: array_search(): Argument #2 ($haystack) must be of type array, null given in …/form-actions.php:407
wp-admin/admin-ajax.php:1
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
forms.js?ver=1.9.1:1 Uncaught TypeError: Cannot read properties of undefined (reading ‘data’)
at Object.error (forms.js?ver=1.9.1:1:4106)
at c (jquery.min.js?ver=3.7.1:2:25304)
at Object.fireWith as rejectWith
at l (jquery.min.js?ver=3.7.1:2:77807)
at XMLHttpRequest. (jquery.min.js?ver=3.7.1:2:80265)
Points to this:
onError: function(t) {
return function(e) {
var a = t.$el.data("acf")
, e = e.responseJSON.data.errors;
a.addErrors(e),
a.showErrors()
}
}
Hope that helps. Would be useful if you could provide some way to hook into this ^^
Hi Theo,
What is the full path to the form-actions.php file?
I don’t really want to start sharing that. But it’s included in functions.php. So you could just add a similar line of code there.
add_action( ‘profile_update’, ‘profile_update_function’, 10, 1 );
Is where the code comes from that is causing the error.
Thanks Theo,
I can’t find that line of code in the plugin. I’ll need more context here. Is it possibly a different plugin that is causing the issue?
Cheers,
Phil
Sorry Phil, I’m not being clear enough. Try this:
Make a form that updates user details.
Inside functions.php add the add_action( ‘profile_update’, ‘profile_update_function’, 10, 1 );
Inside this function, cause a PHP fatal error, such as array_search on a null value. This should then cause the AJAX to fail and the form to freeze with no output/explanation to the user.
Thanks Theo,
I’ll spend some time with this and see if there’s anything I can do in the way of a patch release over the next week or so. I’ll write back here with what I find.
Cheers,
Phil