ajax请求:

一、从服务器端请求数据:

var url = '';
url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='+ appid +'&secret='+ secret +'&code='+ code +'&grant_type=authorization_code';
$.ajax({
type: 'GET',
url: url,
dataType: 'json',
success: function(data){
alert(JSON.stringify(data))
},
error: function(xhr, type){
alert('Ajax error!')
}
});

二、发送数据到服务器

// 参与活动
function joinActivity(msg){
$.ajax({
type: 'GET',
url: 'http://ebsig.mcake.com/ajax-shop/activity/wsj.ajax',
data: { operFlg: 'join', gid: gid, oid:oid, msg: msg},
dataType: 'json',
success: function(data){
if(data.code == 200) {
$('#js_step9').show();
} else {
// 已经参加过
alert(data.message);
}
},
error: function(xhr, type){
alert('Ajax error!')
}
});
}
函数调用:
joinActivity(val);

整体页面js部署:

//初始化设置
var gid = '',
oid = getOid();
$step1 = $('#js_step1'),
$step2 = $('#js_step2'),
$step3 = $('#js_step3'),
$step4 = $('#js_step4'),
$step5 = $('#js_step5'), $step6 = $('#js_step6'),
$step7 = $('#js_step7'),
$step8 = $('#js_step8'),
$step9 = $('#js_step9'),
$step10 = $('#js_step10'),
$step11 = $('#js_step11'),
$step12 = $('#js_step12'),
$step13 = $('#js_step13'),
menTimeer = null; $(function(){
// 初始化weixin 配置
(function initConfig(){
execJs();
})();
// 授权
    function auth(appId){
}
}); function execJs() {
function imgShow(ele){
var i=-1;
var len=ele.children("img").length;
function imgAnimate(){ //设置走光动画
i++;
if(i<len){
setTimeout(function(){
ele.children("img").eq(i).show().siblings().hide();
imgAnimate(); //内部回调
},300);
} }
imgAnimate(); //执行一次动画,否则其他动画不隐藏
}
}
imgShow($("#js_loading"));//立刻执行一次
var timeer = setInterval(function(){imgShow($("#js_loading"))},1200);/*循环执行*/ //loading动画
function imgLoad(ele){} function step1(){
      $step1.hide();
         $step3.show();
    }
function step2(){}
function step3(){} var animation = {
menAnimation: function(){},
cdAnimation: function(){},
zdAnimation: function(){},
sdAnimation: function(){},
}
    // 发起活动
    function initActivity(callback){}
// 查看活动
    function checkActivity(gid){}
    // 参与活动
    function joinActivity(msg){}
    //分享
    function shareWx(url){}   
   (function bindEvent () {
     // 步骤
         $step1.on('click', function(){
             clearInterval(menTimeer);
             step2();
         });
      $step2.on('click', function(){
             $("#js_share").find('img').hide();
            location.href = location.origin + location.pathname + '?gid=' + gid;
step2();
            $step1.hide();
        });
})();
}
var $bao = $('#js_bao'),
$step2 = $('#js_step2'),
$step3 = $('#js_step3'); (function initConfig(){
execJs();
})(); function execJs() {
function step1(){
      $bao.find("li").click(function(){
$(this).addClass("on").siblings().removeClass("on");
})
   } (function bindEvent () {
step1();
})();
}

陈朱兴-js写法【案例】:的更多相关文章

  1. 陈-朱-兴- js写法【案例】:

    ajax请求: 一.从服务器端请求数据: var url = '';url = 'https://api.weixin.qq.com/sns/oauth2/access_token?appid='+ ...

  2. 【Vue.js实战案例】- Vue.js递归组件实现组织架构树和选人功能

    大家好!先上图看看本次案例的整体效果. 浪奔,浪流,万里涛涛江水永不休.如果在jq时代来实这个功能简直有些噩梦了,但是自从前端思想发展到现在的以MVVM为主流的大背景下,来实现一个这样繁杂的功能简直不 ...

  3. js计算器案例

    <!DOCTYPE html><html> <head> <meta charset="UTF-8"> <title>j ...

  4. 正則表達式--js使用案例

    前言:在前端页面使用中.遇到日期格式的验证.開始使用了一款表单控件验证.可是不兼容!!并且使用起来还受到非常大约束.所以就决定自己写原生js. 为了完毕日期格式的验证.第一步,当然是学会使用正則表達式 ...

  5. JS小案例:循环间隔重复变色

    在A.B.C三个区块中,有且仅有一个红色,要求红色每隔一秒即进入下一个区块,变色过程不断循环往复. 参考代码: <!DOCTYPE html> <html lang="zh ...

  6. arttemplate.js简洁写法案例

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  7. arttemplate.js原生写法案例

    <!DOCTYPE html> <html> <head lang="en"> <meta charset="UTF-8&quo ...

  8. node.js(小案例)_实现学生信息增删改

    一.前言 本节内容主要对小案例做一个总结: 1.如何开始搭建小项目 2.路由设计 3.模块应用 4.项目源码以及实现过程github地址: 项目演示如下: 二.主要内容 1.项目的关键性js源码: 项 ...

  9. node.js 爬虫案例

    本案例是爬的一部小说,爬取并存在本地 使用了动态浏览器头部信息,和 动态ip代理, 这2个方式可以有效的伪装自己,不至于被反爬,然后拉黑,之前已有记录,浏览器头部信息,也记录的有, app.js im ...

随机推荐

  1. shape into blocks--source code in python based on pySpark

    这是微博深度和广度预测的原始代码,写了大约半个月,第一个版本不是这样的,但是这个版本包含所有需要的功能. 模块化的程度也更高.找工作前一直想用python完美解决这个问题,后来发现自己的方法和硬件都有 ...

  2. style不同取值对应的日期、时间格式

    from : http://www.cnblogs.com/Gavinzhao/archive/2009/11/10/1599690.html sql server2000中使用convert来取得d ...

  3. 几个移动App测试工具

    介绍几款移动App测试的工具: 腾讯测试:http://bugly.qq.com/优测:http://utest.qq.com/fir.im测试:http://bughd.com/ 大致介绍如下: b ...

  4. iOS - OC Copy 拷贝

    前言 copy:需要先实现 NSCopying 协议,创建的是不可变副本. mutableCopy:需要实现 NSMutableCopying 协议,创建的是可变副本. 浅拷贝:指针拷贝,源对象和副本 ...

  5. Ubuntu Server14.04 32位安装odoo8.0简单方法

    一.wget -O - https://nightly.odoo.com/odoo.key | apt-key add - 二.echo "deb http://nightly.odoo.c ...

  6. python 标准库

    https://www.zhihu.com/question/24590883 https://www.zhihu.com/question/20501628 http://blog.csdn.net ...

  7. WPA/WPA2四次握手

    WPA/WPA2四次握手 官方文档:https://en.wikipedia.org/wiki/IEEE_802.11i-2004 The four-way handshake is designed ...

  8. PHP的UTF-8中文转拼音处理类(性能已优化至极致)

    <?php /** * PHP 汉字转拼音 * @author Jerryli(hzjerry@gmail.com) * @version V0.20140715 * @package SPFW ...

  9. hdu1907(anti-sg入门)

    改变了下规则,现在变成了最后拿的人输. 如果对于单纯的nim的话,只需要判断每堆都是1个石子的特殊情况. 因为如果存在有大于1个石子的堆话,类似于nim的取法,处于必胜状态的一方只需要在 对方取完后只 ...

  10. HA功能中ZKFC对NN状态的控制

    ZKFC : zookeeper FailoverController NN : name node Hadoop 2.0 HA架构图: FC是要和NN一一对应的,两个NN就要部署两个FC.它负责监控 ...