• Hello!

    Please, maybe you have idea & lead me closer to solution:

    My problem: i’m trying to set up the CF7 form to work properly in a WP page with my custom ajax navigation. Seems, i broke something. Can’t find the bug for a while.
    The form works just perfectly after the initial pageload. But, after clicking the nav buttons (my custom- ajax part does the job here), CF7 breaks after submit and prints a “0” as output (with the url: /admin-ajax.php#wpcf7-f409-o1 ) –> so i guess the problem is something like: cf7 form can’t get some crucial data from my ajaxified page.

    You can test it here. Please follow these steps to replicate the issue:

    1. open the page from this link. https://maef-hu.iwanwilaga.com/fotosaink/ancsin-attila/

    2. click on the left or right (nav) buttons on the sides. That switches the content to the “prev” or “next” page. (this is the custom ajax part by me.)

    3. Now click on the blue button below the social icons. The form area turns visible below that.

    4. Submit a form. (Name, Email, Message).

    5. Form prints a “0” on the “/admin-ajax.php#wpcf7-f409-o1” url. (so i guess it’s some kind of ajax communication problem related to the form)

    extra info: when you click on a nav button, ajax asks for the prev or next page accordingly, server runs a new query and sends data back to jQuery to populate the page with the changed elements of the received post object, also it sends the re-generated cf7 form html markup).
    I tried to output the cf7 form either with “echo do_shortcode( ‘[contact-form-7″….
    and also with wp_send_json(), but both gave me the same “0” result.) In both cases the form displays properly, but as you find, the Submit part is broken.

    Thank you for any hints, would be much appreciated, man!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter iwanwilaga

    (@iwanwilaga)

    Since then i got 1 step closer to uncovering the problem. As just found, that after i regenerate the form with the

    do_shortcode( '[contact-form-7 id="409" title="Ajanlat kerese urlap"]' );

    function inside my ajax response handler function, 1 thing is done differently:
    <form action= …value changed

    from this:
    <form action="/fotosaink/ancsin-attila/#wpcf7-f409-p30-o1"
    to this:
    <form action="/wp-admin/admin-ajax.php#wpcf7-f409-o1"
    which seems to be a quite insufficient source to call..

    so i guess i need to find the cf7 function that assembles that attr value and somehow dynamically update its input with the ajax changed new post accordingly to make it work.
    Now i just need to get through this.. do you think its technically possible?

    • This reply was modified 5 years, 1 month ago by iwanwilaga.
    • This reply was modified 5 years, 1 month ago by iwanwilaga.
    • This reply was modified 5 years, 1 month ago by iwanwilaga.
    • This reply was modified 5 years, 1 month ago by iwanwilaga.
    • This reply was modified 5 years, 1 month ago by iwanwilaga.
    • This reply was modified 5 years, 1 month ago by iwanwilaga.
    	$('form.wpcf7-form').each(function() {
    		var action = $(this).attr('action');
    		action = action.substring(action.indexOf('#'));
    		$(this).attr('action', action);
    
    		wpcf7.initForm($(this));
    	});
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘CF7 prints a “0” after ajax submit’ is closed to new replies.