AJAX submission no longer redirects after AIO update

Support MB Frontend Submission AJAX submission no longer redirects after AIO update

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #40546
    Stephen C.Stephen C.
    Participant

    I 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.

    #40547
    Stephen C.Stephen C.
    Participant

    Actually, it looks like the form isn't being submitted via ajax, even though the shortcode is set to submit via ajax.

    #40549
    Stephen C.Stephen C.
    Participant

    It 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'.

    #40565
    PeterPeter
    Moderator

    Hello 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-form

    You 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.

    #40604
    Stephen C.Stephen C.
    Participant

    Not 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.

    #40616
    PeterPeter
    Moderator

    Hello,

    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.

    #41560
    Stephen C.Stephen C.
    Participant

    I 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.

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.