do_shortcode returns nothing in AJAX call

Support MB Frontend Submission do_shortcode returns nothing in AJAX call

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #38945
    pzapza
    Participant

    I can't figure this one out. The same shortcode renders in the template file (non AJAX).

    But via AJAX (code below) returns the err message.

    
    $return = array();
    if ( $formcode = do_shortcode("[mb_frontend_form id='listing-actions' post_fields='title,content']") ) {
    	$return['html'] = $formcode;
    } else {
    	$return['err'] = 'No form returned.';
    }
    echo json_encode($return);
    die;
    

    Is this a known limitation? Any tips appreciated.

    #38950
    PeterPeter
    Moderator

    Hello there,

    It is not possible to render the frontend shortcode via AJAX call because the CSS and JS files will not be loaded along with the HTML code. Please use the shortcode on the page load only to make the shortcode render correctly.

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