WordPress.org

Support

Support » How-To and Troubleshooting » AJAX not working

AJAX not working

  • 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

Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘AJAX not working’ is closed to new replies.