Advertisement
sagaida

index_json.php

Aug 16th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.63 KB | None | 0 0
  1. <!doctype html>
  2. <html>
  3.     <head>
  4.         <meta charset="utf-8">
  5.         <script src="/public/scripts/jquery.min.js"></script>
  6.         <script src="/public/scripts/jquery.cookie.js"></script>
  7.         <title>AJAX</title>
  8.         <style>.red{background:red}</style>
  9.     </head>
  10.  
  11.     <body>
  12.         <form method="post" action="set.php" id="formId">
  13.             <input type="text" name='fio'>
  14.             <input type="text" name='place'>
  15.             <button type="submit">ะคะ˜ะž</button>
  16.         </form>
  17.        
  18.         <script>
  19.             $(function(){
  20.                
  21.                 $("#formId").submit(function(){
  22.                     var form_data = $("#formId").serialize();
  23.                     $("input","#formId").removeClass("red");
  24.                     var is_valid = valid_form();
  25.                    
  26.                    
  27.                     $.ajax({
  28.                         type: "POST",
  29.                         url: "set.php",
  30.                         dataType: "json",
  31.                         data: ({a : '55'}),
  32.                         success: function( data ){
  33.                             for(el in data){
  34.  
  35.                                 $("input[name='"+data[el]+"']").addClass("red");
  36.                             }
  37.                         }
  38.                    });
  39.                    
  40.                    
  41.                    return false;
  42.                 })
  43.                
  44.                
  45.                
  46.             })
  47.            
  48.            
  49.             function valid_form(){
  50.                 return false;
  51.             }
  52.         </script>
  53.        
  54.        
  55.        
  56.     </body>
  57. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement