由于$.post() 和 $.get() 默认是 异步请求,如果需要同步请求,则可以进行如下使用:
在$.post()前把ajax设置为同步:$.ajaxSettings.async = false;
在$.post()后把ajax改回为异步:$.ajaxSettings.async = true;

 $.ajaxSettings.async = false;
$.post(url, {id:id}, function(res) {
if (res.code == ) {
alert(res.message);
e.stopPropagation();
e.preventDefault();
$(this).attr('href','jacascript::void(0)');
}
},"json");

随机推荐

  1. POJ 2406 - Power Strings - [KMP求最小循环节]

    题目链接:http://poj.org/problem?id=2406 Time Limit: 3000MS Memory Limit: 65536K Description Given two st ...

  2. 基于Docker部署nodejs应用

    基于Docker部署nodejs应用 背景 公司基于Vue.js的项目最近需要部署到云端,因此需要先行在公司内部Docker环境下验证相关技术,因而有本文之前提. 本文展示在Docker容器中,应用部 ...

  3. os.path 模块

    os.path.abspath(path) #返回绝对路径 os.path.basename(path) #返回文件名 os.path.commonprefix(list) #返回list(多个路径) ...

  4. LeetCode 第 342 题(Power of Four)

    LeetCode 第 342 题(Power of Four) Given an integer (signed 32 bits), write a function to check whether ...

  5. html+css小总结

    html+css小总结 1.块级元素 <div> <h1> <hr /> <p> <pre> <ol> <ul> & ...

  6. JavaScript如何实现拖放功能

    1.在学习ExtJs时,对其拖放功能感到很陌生,然后找了个拖放功能实现. 转载地址 2.拖拽的基本原理就是根据鼠标的移动来移动被拖拽的元素.鼠标的移动也就是x.y坐标的变化:元素的移动就是style. ...

  7. Spring使用AspectJ注解和XML配置实现AOP

    本文演示的是Spring中使用AspectJ注解和XML配置两种方式实现AOP 下面是使用AspectJ注解实现AOP的Java Project首先是位于classpath下的applicationC ...

  8. 【剑指offer】旋转数组的最小数字

    一.题目: 把一个数组最开始的若干个元素搬到数组的末尾,我们称之为数组的旋转. 输入一个非减排序的数组的一个旋转,输出旋转数组的最小元素. 例如数组{3,4,5,1,2}为{1,2,3,4,5}的一个 ...

  9. Iterator源码解读

    //继承关系 public interface Inteator { boolean hasNext(); Object next(); } public interface Iterable { I ...

  10. POJ:2528(Mayor's posters)离散化成段更新+简单哈希

    http://poj.org/problem?id=2528 Description The citizens of Bytetown, AB, could not stand that the ca ...