由于$.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. java后台设计简单的json数据接口,设置可跨域访问,前端ajax获取json数据

    在开发的过程中,有时候我们需要设计一个数据接口.有时候呢,数据接口和Web服务器又不在一起,所以就有跨域访问的问题. 第一步:简单的设计一个数据接口. 数据接口,听起来高大上,其实呢就是一个简单的Se ...

  2. 字符串-回文-Manacher算法

    http://blog.csdn.net/zzkksunboy/article/details/72600679 https://segmentfault.com/a/1190000008484167 ...

  3. 为什么面试要问 hashmap 的原理

    我们都知道哪里要用HashMap,知道Hashtable和HashMap之间的区别,那么为何这道面试题如此特殊呢?是因为这道题考察的深度很深.这题经常出现在高级或中高级面试中.投资银行更喜欢问这个问题 ...

  4. Silver Cow Party---poj3268(最短路,迪杰斯特拉)

    Silver Cow Party Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u De ...

  5. 【python-opencv】15-图像阈值

    [微语]立志要如山,行道要如水.不如山,不能坚定,不如水,不能曲达 import cv2 as cv import numpy as np from matplotlib import pyplot ...

  6. kubernetes实战(十一):k8s使用openLDAP统一认证

    1.基本概念 为了方便管理和集成jenkins,k8s.harbor.jenkins均使用openLDAP统一认证. 2.部署openLDAP 此处将openLDAP部署在k8s上,openLDAP可 ...

  7. 菜鸟教程之工具使用——Git的基本使用

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/liushuijinger/article/details/37569907 Git是进来比較火的版本 ...

  8. 混淆矩阵在Matlab中PRtools模式识别工具箱的应用

    声明:本文用到的代码均来自于PRTools(http://www.prtools.org)模式识别工具箱,并以matlab软件进行实验. 混淆矩阵是模式识别中的常用工具,在PRTools工具箱中有直接 ...

  9. Weka——PrincipalComponents分析

    package weka.filters.unsupervised.attribute; PrincipalComponents 属性: /** The data to transform analy ...

  10. isKindOfClass isMemeberOfClass 的区分

    isKindOfClass If you use such constructs in your code, you might think it is alright to modify an ob ...