ajax无刷新表单提交

2021-06-17 17:03

阅读:568

标签:ajax   无刷新   表单提交   

ajax无刷新提交笔记

数据库自己模拟建一个 执行一下添加功能

php部分采用pdo方法:

‘SET NAMES \‘UTF8\‘‘); 

$pdo = new PDO($dsn,$user,$pwd,$options);

$name = $_POST[‘name‘];
//print_r ($name);exit;
$pwd  = $_POST[‘pwd‘];
$code  = $_POST[‘code‘];
$sql = "insert into user (name,pwd,code) values (‘".$name."‘,‘".$pwd."‘,‘".$code."‘)";

$res=$pdo->exec($sql);  

if ($res){
   echo 1;
   exit;
}else{
   echo 2;
   exit;
}

ajax前端部分


        

        无刷新用户登录

    
    
     

                    
                        
                                                          
                                        
                                              
    • 用户名: 
    •                                         
    •                                                                                                                               
    •                                    
                                        
                                              
    • 密    码: 
    •                                         
    •                                                                                                                                   
    •                                     
                                        
                                              
    • 身份证: 
    •                                         
    •                                                                                                                                                              
    •                                     
                                                                         
                                                             
  •                                                              
  •                         
                    
                


本文出自 “kangjunfei” 博客,转载请与作者联系!

ajax无刷新表单提交

标签:ajax   无刷新   表单提交   

原文地址:http://kangjunfei.blog.51cto.com/11556647/1952352


评论


亲,登录后才可以留言!