WordPress.org

Ready to get started?Download WordPress

Forums

AJAX not working (4 posts)

  1. jono-catchfire
    Member
    Posted 1 year ago #

    Hello,

    I have created an AJAX form that outside of WordPress. Now that I've gone to integrate it, it's not working so hot.

    You can see this form in action at:

    http://mp.ignitionswitch.biz

    UN: Tester
    PW: testing1

    For some reason I have the form working but the AJAX doesn't seem to be working.

    Here is the code.


    $(function() {
    // Validate the contact form
    $('#contactform').validate({
    // Specify what the errors should look like
    // when they are dynamically added to the form
    errorElement: "label",
    wrapper: "div",
    errorPlacement: function(error, element) {
    error.insertAdjacentElement( element.parent().parent() );
    error.wrap("<div class='error'></div>");
    $("<div></div>").insertBefore(error);
    },

    // Add requirements to each of the fields
    rules: {
    name: {
    required: true,
    minlength: 2
    },
    company: {
    required: true,
    minlength: 2
    },
    employees: {
    required: true,
    minlength: 2
    },
    phone: {
    required: true,
    minlength: 2
    },
    email: {
    required: true,
    email: true
    }
    },

    // Specify what error messages to display
    // when the user does something horrid
    messages: {
    name: {
    required: "Please enter your name.",
    minlength: jQuery.format("At least {0} characters required.")
    },
    company: {
    required: "Please enter your company's name.",
    minlength: jQuery.format("At least {0} characters required.")
    },
    employees: {
    required: "Please enter your company's name.",
    minlength: jQuery.format("At least {0} characters required.")
    },
    phone: {
    required: "Please enter your phone number.",
    minlength: jQuery.format("At least {0} characters required.")
    },
    email: {
    required: "Please enter your email.",
    email: "Please enter a valid email."
    }
    },

    // Use Ajax to send everything to processForm.php
    submitHandler: function(form) {
    $("#send").attr("value", "Sending...");
    $(form).ajaxSubmit({
    target: "#response",
    success: function(responseText, statusText, xhr, $form) {
    $(form).slideUp("fast");
    $("#response").html(responseText).hide().slideDown("fast");
    }
    });
    return false;
    }
    });
    });

    My form uses:
    jQuery Validate plugin
    jQuery Form plugin

  2. jono-catchfire
    Member
    Posted 1 year ago #

    If any one can help me know why my AJAX isn't working that would be great! Any leads would be most appreciated.

  3. jono-catchfire
    Member
    Posted 1 year ago #

    From what I'm looking at I think I need to add something to functions.php but not quite sure what to add.

  4. jono-catchfire
    Member
    Posted 1 year ago #

    Sorry one last note in case you are wondering where the form is it slides out on the right from the free quote tab.

Topic Closed

This topic has been closed to new replies.

About this Topic