您现在的位置: 爱51代码网 >> 范文 >> 文章正文
jquery ajax的发生错误error:200

jquery ajax的发生错误error:200

Remote Address:[::1]:80
Request URL:http://localhost/yangwei/admin/zhuce.php
Request Method:POST
<span style="color: #FF0000;">Status Code:200 OK</span>
Request Headersview source
Accept:application/json, text/javascript, */*; q=0.01
Accept-Encoding:gzip,deflate
Accept-Language:zh-CN,zh;q=0.8
Connection:keep-alive
Content-Length:53
Content-Type:application/x-www-form-urlencoded; charset=UTF-8
Cookie:PHPSESSID=u1dqcsarob79jg52ls7phod7j4
Host:localhost
Origin:http://localhost
<span style="color: #FF0000;">Referer:http://localhost/yangwei/user/zhuce.html</span>
User-Agent:Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36
X-Requested-With:XMLHttpRequest
Form Dataview sourceview URL encoded
sname:李四
pwd:123456
phone:13137773333
Response Headersview source
Cache-Control:no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Connection:Keep-Alive
Content-Length:1622
<span style="color: #FF0000;">Content-Type:application/json;charset=utf-8</span>
Date:Wed, 18 Mar 2015 09:21:45 GMT
Expires:Thu, 19 Nov 1981 08:52:00 GMT
Keep-Alive:timeout=5, max=100
Pragma:no-cache
Server:Apache/2.4.9 (Win32) PHP/5.5.12
X-Powered-By:PHP/5.5.12

$(document).ready(function(){
        //注册
        $("#zhuce").click(function(){
            $.ajax({
                type:"POST",
                url:"../admin/zhuce.php",
                dataType:"json",
                data:{
                      "sname":$("#sname").val(),"pwd":  $("#pwd").val(),"phone":$("#phone").val(),
                      },
                success:function(data){
                      if(data.success){
                          $("#vzhuce").html(data.msg);
                          setTimeout(function(){window.location="../index.php";},3000);
                          }else{
                          $("#vzhuce").html("error: "+data.msg);
                          }
                      },
                error:function(jqXHR){
                    alert("发生错误: "+jqXHR.status);
                      },
                });
            });
    });

后台PHP页:
 
//注册
function zhuce()
{
    header("Content-type:application/json;charset=utf-8");
    $sname = trim($_POST["sname"]);
    $pwd = trim($_POST["pwd"]);
    $phone = trim($_POST["phone"]);
if(!isset($sname) || empty($sname)
 ||!isset($pwd) || empty($pwd)
 ||!isset($phone) || empty($phone))
 {
     echo '{"success":false,"msg":"输入参数不全"}';
     return;
     }
else{
$rs=mysql_query("INSERT INTO `tb_user`(`sname`, `pwd`, `phone`) VALUES ('$sname','$pwd','$phone')",$link);
if($rs)
{
    $_SESSION['user']=$sname;
    echo '{"success":true,"msg":"注册成功,即将进入首页!"}';
    exit;
}
}
}1、去掉程序文件的 BOM 头
2、去掉 header("Content-type:application/json;charset=utf-8");

$(document).ready(function(){
        //注册
        $("#zhuce").click(function(){
            $.ajax({
                type:"POST",
                url:"../admin/zhuce.php",
             // dataType:"json",
                data:{
                      "sname":$("#sname").val(),"pwd":  $("#pwd").val(),"phone":$("#phone").val(),
                      },
                success:function(data){
                      alert(data);
                      if(data.success){
                          $("#vzhuce").html(data.msg);
                          setTimeout(function(){window.location="../index.php";},3000);
                          }else{
                          $("#vzhuce").html("error: "+data.msg);
                          }
                      },
                error:function(jqXHR){
                    alert("发生错误: "+jqXHR.status);
                      },
                });
            });
    });

  • 上一篇文章:

  • 下一篇文章: 没有了
  • 最新文章 热点文章 相关文章
    SharePoint 2013 Search REST AP
    SharePoint如何搜索指定的爬网内
    weblogic Servlet: "action" fai
    webdav 与exchange通信失败未找到
    SharePoint2013文档库可以直接存
    Unable to write data to the tr
    asp.net中listbox的items.count属
    C#不是每次查询数据是不是被缓存
    ASP.NET发布后能加载引用的js文件
    Hadoop2.2.0在eclipse控制台没有
    SharePoint 2013 Search REST AP
    SharePoint如何搜索指定的爬网内
    weblogic Servlet: "action" fai
    webdav 与exchange通信失败未找到
    SharePoint2013文档库可以直接存
    Unable to write data to the tr
    asp.net中listbox的items.count属
    C#不是每次查询数据是不是被缓存
    ASP.NET发布后能加载引用的js文件
    Hadoop2.2.0在eclipse控制台没有
    60行代码网页版俄罗斯方块
    保留小数点后两位然后将其转
    如何根据设备显示定制的网页
    如何让html生成app
    jQuery Autocomplete not wo
    xml取不到createElement后的
    asp导出csv文件后数字会自动
    ajaxSubmit提交带有文本编辑
    easyUI控件表格最后一列空白
    长时间不操作页面,等再次操
     



    设为首页 | 加入收藏 | 网站地图 | 友情链接 |