Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form id="formoid" action="studentFormInsert.php" title="" method="post">
- <div><label class="title">First Name</label><input type="text" id="name" name="name" ></div>
- <div><label class="title">Name</label><input type="text" id="name2" name="name2" ></div>
- <div><input type="submit" id="submitButton" name="submitButton" value="Submit"></div>
- <script type="text/javascript">
- $(document).ready(function() {
- $('#formoid').ajaxForm(function() {
- alert("Thank you for your comment!");
- });
- });
- </script>
- <!DOCTYPE html>
- <html>
- <head>
- <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
- </head>
- <body>
- <form id="formoid" action="studentFormInsert.php" title="" method="post">
- <div>
- <label class="title">First Name</label>
- <input type="text" id="name" name="name" >
- </div>
- <div>
- <label class="title">Name</label>
- <input type="text" id="name2" name="name2" >
- </div>
- <div>
- <input type="submit" id="submitButton" name="submitButton" value="Submit">
- </div>
- </form>
- <script type='text/javascript'>
- /* attach a submit handler to the form */
- $("#formoid").submit(function(event) {
- /* stop form from submitting normally */
- event.preventDefault();
- /* get some values from elements on the page: */
- var $form = $( this ),
- url = $form.attr( 'action' );
- /* Send the data using post */
- var posting = $.post( url, { name: $('#name').val(), name2: $('#name2').val() } );
- /* Alerts the results */
- posting.done(function( data ) {
- alert('success');
- });
- });
- </script>
- </body>
- </html>
- $.post("test.php", $("#testform").serialize());
- <!DOCTYPE html>
- <html>
- <head>
- <script src="http://code.jquery.com/jquery-1.9.1.js"></script>
- </head>
- <body>
- <form action="/" id="searchForm">
- <input type="text" name="s" placeholder="Search..." />
- <input type="submit" value="Search" />
- </form>
- <!-- the result of the search will be rendered inside this div -->
- <div id="result"></div>
- <script>
- /* attach a submit handler to the form */
- $("#searchForm").submit(function(event) {
- /* stop form from submitting normally */
- event.preventDefault();
- /* get some values from elements on the page: */
- var $form = $(this),
- term = $form.find('input[name="s"]').val(),
- url = $form.attr('action');
- /* Send the data using post */
- var posting = $.post(url, {
- s: term
- });
- /* Put the results in a div */
- posting.done(function(data) {
- var content = $(data).find('#content');
- $("#result").empty().append(content);
- });
- });
- </script>
- </body>
- </html>
- var postData = "text";
- $.ajax({
- type: "post",
- url: "url",
- data: postData,
- contentType: "application/x-www-form-urlencoded",
- success: function(responseData, textStatus, jqXHR) {
- alert("data saved")
- },
- error: function(jqXHR, textStatus, errorThrown) {
- console.log(errorThrown);
- }
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement