PHP后台

一、ajax提交表单

先引入ajax.js

 1 function ajax(url, fnSucc, fnFaild)
 2 {
 3     //1.创建Ajax对象
 4     var oAjax=null;
 5     
 6     if(window.XMLHttpRequest)
 7     {
 8         oAjax=new XMLHttpRequest();
 9     }
10     else
11     {
12         oAjax=new ActiveXObject("Microsoft.XMLHTTP");
13     }
14     
15     //2.连接服务器
16     oAjax.open('GET', url, true);
17     
18     //3.发送请求
19     oAjax.send();
20     
21     //4.接收服务器的返回
22     oAjax.onreadystatechange=function ()
23     {
24         if(oAjax.readyState==4)    //完成
25         {
26             if(oAjax.status==200)    //成功
27             {
28                 fnSucc(oAjax.responseText);
29             }
30             else
31             {
32                 if(fnFaild)
33                     fnFaild(oAjax.status);
34             }
35         }
36     };
37 }

然后

1 var url='loginAct.php?user='+oTxt.value;//alert(url);
2         ajax(url,function(str){console.log(str);
3             if(str==1){
4                 oUser.value=oTxt.value+'Welcome to here';//alert('Welcome to here');
5             }else{
6                 alert('your name is error');
7             }
8         });