zoukankan      html  css  js  c++  java
  • ajax验证表单

     1 <script type="text/javascript">
     2         $(function(){
     3             //点击按钮异步加载数据,并在content中显示
     4             $("#btn").click(function(){
     5 
     6                 /**** $.ajax()方法  ***
     7 //                $.ajax({
     8 //                    url: "data.json",//"发送的请求地址",
     9 //                    type:"get",//"请求方式"
    10 //                    data:null,//"要发送的数据",
    11 //                    dataType: "json",
    12 //                    beforeSend: function(data) { // 发送请求前执行的代码
    13 //                        $(".loading").show();
    14 //                    },
    15 //                    success: function(data) {// 发送成功后执行的代码
    16 //                        dealData(data);
    17 //                    },
    18 //                    complete:function(){
    19 //                        $(".loading").hide();
    20 //                    },
    21 //                    error: function(XMLHttpRequest, textStatus, errorThrown) {// 请求失败执行的代码
    22 //                        alert("错误信息:"+textStatus);
    23 //                    }
    24 //                 });
    25 //
    26 
    27                 /****  $.getJSON()方法  ****/
    28 //                $.getJSON("data.json",function(data){
    29 //                    dealData(data);
    30 //                })
    31 
    32                 /****  $.get()方法   ****/
    33 //                $.get("data.json",{},function(data){
    34 //                    dealData(data);
    35 //                },"json");
    36                 
    37                 /****  $.post()方法  ****/
    38                 $.post("data.json",{},function(data){
    39                     dealData(data);
    40                 },"json")
    41 
    42 
    43             });
    44             function dealData(data){
    45                 if(typeof data != "undefined"){
    46                     $(data.news).each(function(i){
    47                         $("#newsList").append("<li><a href='#id="+data.news[i].id+"'>"+data.news[i].title+"["+data.news[i].date+"]</a></li>")
    48                     });
    49                 }
    50             }
    51         });
    52     </script>
  • 相关阅读:
    求二维数组的最大子集和
    电梯调度《二》
    电梯调度问题
    BIEE 通过提示器选择展示列(列名接收表示变量)
    BIEE时间序列函数
    Python学习笔记(三)
    Python学习笔记(二)
    Python学习笔记(一)
    BIE前台常用设置
    BIEE 连接BW query query结构 引用
  • 原文地址:https://www.cnblogs.com/go4mi/p/5492712.html
Copyright © 2011-2022 走看看