AJAX submission no longer redirects after AIO update
Support › MB Frontend Submission › AJAX submission no longer redirects after AIO update
- This topic has 6 replies, 2 voices, and was last updated 2 years ago by
Stephen C..
-
AuthorPosts
-
February 16, 2023 at 9:12 AM #40546
Stephen C.
ParticipantI updated to the newest AIO, but now when a frontend form is submitted via AJAX, the user is no longer redirected. The json response just appears on a blank page. Previously, when the form was successfully submitted, it scrolled up to the top where the success message was displayed and after a brief pause, it would redirect to the "redirect" page as defined in the json response.
I'm not sure if it's something on my end that needs to be fixed or if the javascript in the new AIO package for Frontend Submission has an error or is missing something.
February 16, 2023 at 9:25 AM #40547Stephen C.
ParticipantActually, it looks like the form isn't being submitted via ajax, even though the shortcode is set to submit via ajax.
February 16, 2023 at 10:13 AM #40549Stephen C.
ParticipantIt appears that in Form.php in the following function
private function enqueue() { wp_enqueue_style( 'mbfs-form', MBFS_URL . 'assets/form.css', '', MBFS_VER ); wp_enqueue_script( 'mbfs', MBFS_URL . 'assets/frontend-submission.js', array( 'jquery' ), MBFS_VER, true ); $this->localize_data = array_merge( $this->localize_data, [ 'ajaxUrl' => admin_url( 'admin-ajax.php' ), 'nonce' => wp_create_nonce( 'ajax_nonce' ), 'ajax' => $this->config['ajax'], 'redirect' => $this->config['redirect'], 'confirm_delete' => __( 'Are you sure to delete this post?', 'mb-frontend-submission' ), ] ); }
'ajax' is always getting set to false, regardless of what the shortcode value is for 'ajax'.
February 16, 2023 at 11:02 PM #40565Peter
ModeratorHello Stephen,
I do not see any issue with the setting
ajax="true"
when using the frontend submission shortcode. There are some updates to the form and you can read more on the documentation https://docs.metabox.io/extensions/mb-frontend-submission/#submission-formYou can try to deactivate all plugins except Meta Box, MB extensions, switch to a standard theme of WordPress and recheck this issue on your site.
February 19, 2023 at 12:49 PM #40604Stephen C.
ParticipantNot sure why the new version always sets the ajax value in the javascript created by localize_data to "false" on my site, but I ended up having to revert back to the previous version of Frontend Submisssion, because that version works for me. I currently don't have the time to fully investigate the issue.
Also, two identical lines of javascript are created in <script id='mbfs-js-extra'> (the localized data). Not sure what's going on there, either, but that obviously wouldn't cause any problems.
February 20, 2023 at 7:30 PM #40616Peter
ModeratorHello,
You can try to check this issue again in a fresh install of WordPress and Meta Box. Let me know if the issue still happens.
April 20, 2023 at 7:12 PM #41560Stephen C.
ParticipantI finally figured it out. At some point you guys made it so 'ajax' is always false if 'edit' is true. I don't really get why you did that. For my site, the users can edit their submissions and ajax still needs to be true. So, I had to edit the source code to get it to work. I know it's not ideal, but it's the only way to get it to work as needed.
-
AuthorPosts
- You must be logged in to reply to this topic.