Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9079005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T19:44:59+00:00 2026-06-16T19:44:59+00:00

I am not very familiar with jQuery but have come across this code for

  • 0

I am not very familiar with jQuery but have come across this code for sending an email via a from using jQuery from a site.

What im stuck on is that usually at least in HTML/PHP you would have a POST/GET and a URL to point it all to.

There is the line at the end:

$.ajax({
type: ‘POST’,
url: options.url,

but i am not sure how to deal with that on the sever end. Any ideas or pointers ?

Thanks & Happy New Year.

(function($){

    //define the new for the plugin ans how to call it  
    $.fn.contactable = function(options) {
        //set default options  
        var defaults = {
            name: 'Name',
            email: 'Email',
            message : 'Message',
            subject : 'A contactable message',
            submit : 'SEND',
            recievedMsg : 'Thank you for your message',
            notRecievedMsg : 'Sorry but your message could not be sent, try again later',
            disclaimer: 'Please feel free to contact us',
            hideOnSubmit: false

        };

        //call in the default otions
        var options = $.extend(defaults, options);
        //act upon the element that is passed into the design    
        return this.each(function() {
            //construct the form
            var this_id_prefix = '#'+this.id+' ';
            $(this).html('<div id="contactable_inner"></div><form id="contactForm" method="" action=""><div id="loading"></div><div id="callback"></div><div class="holder"><p><label for="name">'+options.name+'<span class="red"> * </span></label><br /><input id="name" class="contact" name="name"/></p><p><label for="email">'+options.email+' <span class="red"> * </span></label><br /><input id="email" class="contact" name="email" /></p><p><label for="message">'+options.message+' <span class="red"> * </span></label><br /><textarea id="message" name="message" class="message" rows="4" cols="30" ></textarea></p><p><input class="submit" type="submit" value="'+options.submit+'"/></p><p class="disclaimer">'+options.disclaimer+'</p></div></form>');
            //show / hide function
            $(this_id_prefix+'div#contactable_inner').toggle(function() {
                $(this_id_prefix+'#overlay').css({display: 'block'});
                $(this).animate({"marginLeft": "-=5px"}, "fast"); 
                $(this_id_prefix+'#contactForm').animate({"marginLeft": "-=0px"}, "fast");
                $(this).animate({"marginLeft": "+=387px"}, "slow"); 
                $(this_id_prefix+'#contactForm').animate({"marginLeft": "+=390px"}, "slow"); 
            }, 
            function() {
                $(this_id_prefix+'#contactForm').animate({"marginLeft": "-=390px"}, "slow");
                $(this).animate({"marginLeft": "-=387px"}, "slow").animate({"marginLeft": "+=5px"}, "fast"); 
                $(this_id_prefix+'#overlay').css({display: 'none'});
            });

            //validate the form 
            $(this_id_prefix+"#contactForm").validate({
                //set the rules for the fild names
                rules: {
                    name: {
                        required: true,
                        minlength: 2
                    },
                    email: {
                        required: true,
                        email: true
                    },
                    message: {
                        required: true
                    }
                },
                //set messages to appear inline
                    messages: {
                        name: "",
                        email: "",
                        message: ""
                    },          

                submitHandler: function() {
                    $(this_id_prefix+'.holder').hide();
                    $(this_id_prefix+'#loading').show();
$.ajax({
  type: 'POST',
  url: options.url,
  data: {subject:options.subject, name:$(this_id_prefix+'#name').val(), email:$(this_id_prefix+'#email').val(), message:$(this_id_prefix+'#message').val()},
  success: function(data){
                        $(this_id_prefix+'#loading').css({display:'none'}); 
                        if( data == 'success') {
                            $(this_id_prefix+'#callback').show().append(options.recievedMsg);
                            if(options.hideOnSubmit == true) {
                                //hide the tab after successful submition if requested
                                $(this_id_prefix+'#contactForm').animate({dummy:1}, 2000).animate({"marginLeft": "-=450px"}, "slow");
                                $(this_id_prefix+'div#contactable_inner').animate({dummy:1}, 2000).animate({"marginLeft": "-=447px"}, "slow").animate({"marginLeft": "+=5px"}, "fast"); 
                                $(this_id_prefix+'#overlay').css({display: 'none'});    
                            }
                        } else {
                            $(this_id_prefix+'#callback').show().append(options.notRecievedMsg);
                            setTimeout(function(){
                                $(this_id_prefix+'.holder').show();
                                $(this_id_prefix+'#callback').hide().html('');
                            },2000);
                        }
                    },
  error:function(){
                        $(this_id_prefix+'#loading').css({display:'none'}); 
                        $(this_id_prefix+'#callback').show().append(options.notRecievedMsg);
                                        }
});     
                }
            });
        });
    };

})(jQuery);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T19:45:01+00:00Added an answer on June 16, 2026 at 7:45 pm

    Receive the data at server as you would a form.

    all of the data being sent by the AJAX request is defined here ( part of the AJAX options object):

    data: {subject:options.subject, 
           name:$(this_id_prefix+'#name').val(), 
            email:$(this_id_prefix+'#email').val(),
             message:$(this_id_prefix+'#message').val()},
    

    In php:

    $email=$_POST['email'];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am not really familiar with jQuery. I have this code that I downloaded
I have not used jquery much yet and not very familiar with it. Trying
I am using ApacheDS version 2.0.0-M3 (I not very familiar with how this works).
This may seem like a very basic question, since I'm not familiar with jQuery,
I'm fairly new to JS and not very familiar with jQuery, but I'd like
I'm not very familiar in programming databases, but I have a Mysql-Database which I
I'm not familiar at all with JQuery and I'm not very good with CSS,
Not very sure if this is the right way of asking, but I was
Ok so I'm not very familiar with Jquery as to know the possible cause
Please excuse my ignorance I am not very familiar with JavaScript and have been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.