6

I've got a freeform form that is setup to be ajax submitted. However, even though it all works and it sends an e-mail without page refresh, i don't get a json message back, it gives me a full webpage in the response.

My freeform code is like:

{exp:freeform:form
collection="Single Product Enquiry"
required=""
notify="me@me.com"
template="single_product_enquiry_form"
ajax="yes"
form:id="ajax_form"
}

and ajax code like this:

$('#ajax_form').ajaxForm(function(data) {
                if(data.success === true)
                {
                    $("#modal-action").hide();
                    $("#modal-reaction").show();
                }

                if(data.success === false)
                {
                    //$(".form-error-holder").html("<label class='error'>"+data.errors.join(', ')+"</label><input type='text' class='error' /><small class='error'>Invalid entry</small>");

                    $.each(data.errors, function(i, item)
                    {
                        $(".form-error-holder").append("<small class='error'>"+i+": "+item+"</small>");
                    });
                }
            });

But i'm just not getting that json response. Any idea why?

  • 1
    is ajax="yes" required? I thought freeform autodetects that (for graceful degradation on the client). Could it be that you're actually accidentally triggering ajax="no" with that param? – Tom Davies Nov 28 '12 at 15:36
  • Well, i do believe that you sir are a legend! If you add that as an answer rather than a comment, i'll accept it and upvote it! Thanks!! – JohnWBaxter Nov 28 '12 at 15:59
  • n.p. answer added - really it's lazy of solspace not to check for ajax="no" rather than just the presence of an ajax param but I suspect it's for speed of parsing. – Tom Davies Nov 28 '12 at 16:02
  • Sure, it also transpires that i was a whole version behind. So, perhaps that is not the case in the latest version. I'm very grateful for the help, cheers! – JohnWBaxter Nov 28 '12 at 16:11
  • Yep. that'll do it to :) – Tom Davies Nov 28 '12 at 16:11
6

Are you sure that ajax="yes" is required?

I believe freeform autodetects that (for graceful degradation on the client).

I haven't checked the FreeForm source but I suspect it could be that you're actually accidentally triggering ajax="no" with that param.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.