使用Ajax提交表单[关闭]

Closed. This question needs details or clarity. It is not currently accepting answers.
                </div>
            </div>
        </div>
                <hr class="my12 outline-none baw0 bb bc-powder-2">
            <div class="grid fw-nowrap fc-black-600">
                    <div class="grid--cell mr8">
                        <svg aria-hidden="true" class="svg-icon iconLightbulb" width="18" height="18" viewbox="0 0 18 18"><path d="M9.5.5a.5.5 0 0 0-1 0v.25a.5.5 0 0 0 1 0V.5zm5.6 2.1a.5.5 0 0 0-.7-.7l-.25.25a.5.5 0 0 0 .7.7l.25-.25zM1 7.5c0-.28.22-.5.5-.5H2a.5.5 0 0 1 0 1h-.5a.5.5 0 0 1-.5-.5zm14.5 0c0-.28.22-.5.5-.5h.5a.5.5 0 0 1 0 1H16a.5.5 0 0 1-.5-.5zM2.9 1.9c.2-.2.5-.2.7 0l.25.25a.5.5 0 1 1-.7.7L2.9 2.6a.5.5 0 0 1 0-.7z" fill-opacity=".4"></path><path opacity=".4" d="M7 16h4v1a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1v-1z" fill="#3F3F3F"></path><path d="M15 8a6 6 0 0 1-3.5 5.46V14a1 1 0 0 1-1 1h-3a1 1 0 0 1-1-1v-.54A6 6 0 1 1 15 8zm-4.15-3.85a.5.5 0 0 0-.7.7l2 2a.5.5 0 0 0 .7-.7l-2-2z" fill="#FFC166"></path></svg>
                    </div>
                <div class="grid--cell lh-md">
                    <p class="mb0">
                        <b>Want to improve this question?</b> Add details and clarify the problem by <a href="/posts/21822209/edit">editing this post</a>.
                    </p>
                    <p class="mb0 mt6">Closed <span title="2014-02-17 09:43:20Z" class="relativetime">6 years ago</span>.</p>
                </div>
            </div>
    </aside>

this is my form i need to submit this only in ajax. i want just submit with ajax in simple html my total code is working fine i have to submit with ajax nothing else

       <html>
  <head>

   <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
   <script src="http://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>
  <script>
$(function() {
$("#register-form").validate({
    rules: {
        name: "required",
        email: {
            required: true,
            email: true
        },
        Budget: {
            required: true,
        },
        phone:"required",
        budget:"required",
        agree: "required"
    },
    messages: {
        name: "Please enter your Name",
        email: "Please enter a valid Email address",
        phone: "Please enter a valid Phone Number",
        Budget: "Please Select a Budget",
        agree: "Please accept our policy"
    },
    submitHandler: function(form) {
    alert("success");
        form.submit();
    }
});
});
  </script>
    </head>
     <body>
    <form action="" method="post" id="register-form" novalidate="novalidate">
        <div class="label">Name</div><input type="text" id="name" name="name" /><br />
        <div class="label">Email</div><input type="text" id="email" name="email" /><br />
        <div class="label">Phone Number</div><input type="text" id="phone" name="phone" /><br />
        <div class="label">budget</div>
        <select id="Budget" name="Budget">
            <option value="">select</option>
            <option value="1">0-100</option> <!-- first option contains value="" -->
            <option value="2">100-200</option> 
            <option value="3">200-300</option> 
        </select>
        <br />
        <div style="margin-left:140px;"><input type="submit" name="submit" value="Submit" /></div>
    </form>
</body>

this is my form i need to submit this only in ajax. i want just submit with ajax in simple html my total code is working fine i have to submit with ajax nothing else

</div>

create a javascript function and call it on form onsubmit event.

in the function , serialise the form data in a json array and post it to the page you want using simple ajax call

You can define ajax call on submitHandler like;

submitHandler: function(form) {
        $(form).ajaxSubmit({
            url:"echo/html",
            type:"GET",
            success: function(response){
             alert(response)
            }
        });        
}

Here is a working fiddle: http://jsfiddle.net/2fC3Z/

Use the code similiar to the below one

        $.ajax({
            type: "PUT",
            url: "http://xxxxxx.com/post.php",
            contentType: "application/json",
            data: JSON.stringify({
                name: "Tricia",
                age: 37
            }),
            dataType: "text",
            success: function( response ){

                // Put the plain text in the PRE tag.
                $( "#putResponse" ).text( response );

            },
            error: function( error ){

                // Log any error.
                console.log( "ERROR:", error );

            },
            complete: function(){

                // When this completes, execute teh
                // DELETE request.
                makeDELETERequest();

            }
        });