首页 > Web开发 > 详细

Jquery中ajax基本语法

时间:2019-12-15 12:58:26      阅读:81      评论:0      收藏:0      [点我收藏+]
一.$.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;
    }
    //代码处理
});

Jquery中ajax基本语法

原文:https://www.cnblogs.com/yeshaoxiang/p/12043714.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!