Advertisement
Guest User

Untitled

a guest
Nov 6th, 2012
302
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 3.13 KB | None | 0 0
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  2. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3.  
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <head>
  6.  
  7. <title>Submit  Form with out refreshing page Tutorial</title>
  8.  
  9. <!-- Meta Tags -->
  10. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  11.  
  12. <!-- CSS -->
  13. <link rel="stylesheet" href="css/structure.css" type="text/css" />
  14. <link rel="stylesheet" href="css/form.css" type="text/css" />
  15.  
  16. <!-- Javascript -->
  17. <script type="text/javascript" src="http://ajax.googleapis.com/ajax/
  18. libs/jquery/1.3.0/jquery.min.js"></script>
  19. <script type="text/javascript">
  20. $(function() {
  21.  
  22. $(".submit").click(function() {
  23.  
  24.  
  25.     var name = $("#name").val();
  26.     var username = $("#username").val();
  27.    
  28.          
  29.    
  30.     var dataString = 'name='+ name + '&ph=' + username;
  31.    
  32.    
  33.    
  34.     if(name=='' || username=='')
  35.     {
  36.     $('.success').fadeOut(200).hide();
  37.  
  38.     $('.error').fadeOut(200).show();
  39.    
  40.     }
  41.    
  42.    
  43.     else
  44.     {
  45.     $.ajax({
  46.     type: "POST",
  47.     url: "http://funiks.com/invoice/phonebook/submit_new_contact_ajax.php",
  48.     data: dataString,
  49.     success: function(){
  50.     $('.success').fadeIn(200).show();
  51.     $('.error').fadeOut(200).hide();
  52.        
  53.    }
  54. });
  55.  
  56.  
  57.  
  58.  
  59.     }
  60.        
  61.  
  62.     return false;
  63.     });
  64.  
  65.  
  66.  
  67. });
  68. </script>
  69. <style type="text/css">
  70. body{
  71. background:url(http://s3.amazonaws.com/twitter_production/profile_background_images/6250979/bgtwitter.jpg) no-repeat;
  72. }
  73. .error{
  74.    
  75.     color:#d12f19;
  76.     font-size:12px;
  77.    
  78.        
  79.     }
  80.     .success{
  81.    
  82.     color:#006600;
  83.     font-size:12px;
  84.    
  85.        
  86.     }
  87. </style>
  88.  
  89.  
  90.  
  91.  
  92.  
  93.  
  94. </head>
  95.  
  96. <body id="public">
  97.     <div style="height:30px"></div>
  98.  
  99. <div id="container">
  100.  
  101. <div style="height:30px"></div>
  102.  
  103. <form autocomplete="off"
  104.     enctype="multipart/form-data" method="post"  name="form">
  105.  
  106. <div class="info" style="padding-left:20px">
  107.     <h2>Submit Form Values with jQuery and Ajax</h2>
  108.     <div>More tutorials <a href="http://9lessons.blogspot.com" style="color:#0066CC; font-weight:bold">http://9lessons.blogspot.com</a> </div>
  109. </div>
  110.  
  111. <ul>
  112.        
  113.    
  114. <li id="foli1"      class="   ">
  115.     <label class="desc" id="title1" for="Field1">
  116.         Full Name           </label>
  117.     <div>
  118.         <input id="name"            name="name"             type="text"             class="field text medium"           value=""            maxlength="255"             tabindex="1"                        />
  119.         </div>
  120.     </li>
  121.    
  122.  
  123.  
  124.  
  125.  
  126.  
  127. <li id="foli3"      class="   ">
  128.     <label class="desc" id="title3" for="Field3">
  129.         User-ID         </label>
  130.     <div>
  131.         <input id="username"            name="username"             type="text"             class="field text medium"           value=""            maxlength="255"             tabindex="3"                        />
  132.         </div>
  133.     </li>
  134.  
  135.  
  136.  
  137.  
  138.  
  139.    
  140. </ul>
  141. <div class="buttons">
  142.                 <input  type="submit" value="Submit" style=" background:#0060a1; color:#FFFFFF; font-size:14px; border:1px solid #0060a1; margin-left:12px" class="submit"/><span class="error" style="display:none"> Please Enter Valid Data</span><span  class="success" style="display:none"> Registration Successfully.......... Click To <a href="http://9lessons.blogspot.com" style="color:#0066CC; font-weight:bold">http://9lessons.blogspot.com</a></span>
  143.       </div>
  144. </form>
  145. <div style="height:20px"></div>
  146. </div><!--container-->
  147. </body>
  148. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement