zoukankan      html  css  js  c++  java
  • Jquery中ajax基本语法

    一.$.ajax的基本使用结构
    var response = $.ajax({
            type: "POST",
            url: "/index.php?m=content&c=index&a=getList",
            data: {
                "page" : currentPage,
                "pTime":new Date().getTime()
            },
            dataType: "json",
            beforeSend:function(){
                //发送时的代码提示
            },
            success: function(data){
                //成功时的代码提示
            },
            complete:function(){
                //完成时的代码提示
            },
            error: function (msg){
                //报错时的代码提示
            },
            async: true
        });
    二.$.post的基本使用结构
    var data = {
          'page':page,
          'pagesize':pagesize,
          'type': type
        }
        $.post(
            '/index.php?m=content&c=index&a=index',
            data,
            function(data){
                console.log(data);
            },
            'json'
        );
    三.$.ajax的onready事件
    $(function(){
         //加载事件
    });
    $(document).ready(function(){
      //加载事件
    });
    四.juery的on方法绑定动态元素的点击事事件
    /**
     * 事件绑定处理
     */
    jQuery(document).on("click","[rel='zanLink']",function(event){
        //判断是否登陆
        if(!jQuery.cookie("58haha_t")){
          window.location.href = passport_login;
          return false;
        }
        //代码处理
    });
  • 相关阅读:
    20180827 360笔试客观题
    20180821 hikvision笔试
    20180820 美团一面
    20180811 网易
    20180811 多益网络
    20180810 多益网络模拟笔试
    hbase --知识点总结
    flume知识点总结
    oracle --hint总结
    查看oracle的执行计划
  • 原文地址:https://www.cnblogs.com/yeshaoxiang/p/12043714.html
Copyright © 2011-2022 走看看