$.post 和 $.get 设置同步和异步请求
由于$.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");
随机推荐
- ububtu16.04下安装protobuf
重新下载protobuf,我下载的时最新的protobuf-all-3.5.1.tar.gz protobuf网址:https://github.com/google/protobuf/relea ...
- POJ - 1088 滑雪 dp
http://bailian.openjudge.cn/practice/1088?lang=en_US 题解: 设一个dp[N][N]数组代表从(i,j)坐标开始能滑到的最远距离.更新的方法为 遍历 ...
- Oracle安装部署之一键安装oracle数据库及其脚本
准备工作:通过ftp工具上传oracle安装软件到linux系统/mnt目录下,并通过unzip命令解压软件.--------------------------------------------- ...
- intptr_t、uintptr_t数据类型的解析
https://blog.csdn.net/cs_zhanyb/article/details/16973379 2013年11月26日 22:20:09 binggo 阅读数:14066 最近开 ...
- 网站优化不等于搜索引擎优化SEO
对于SEO相信搞网络营销的人基本上都知道这个名词,英文全称为search engine optimization,中文一般叫搜索引擎优化,也有的叫搜索引擎定位(Search Engine Positi ...
- sql 对某列取值进行if判断
select if(area_id =350000, 1, 2) as area_id from my_table 取地区编号为350000的设置成 1, 其他的设置成2
- Python开发【笔记】:what?进程queue还能生产出线程!
进程queue底层用线程传输数据 import threading import multiprocessing def main(): queue = multiprocessing.Queue() ...
- 【剑指offer】 二叉树中和为某一值的路径
一.题目: 输入一颗二叉树的跟节点和一个整数,打印出二叉树中结点值的和为输入整数的所有路径.路径定义为从树的根结点开始往下一直到叶结点所经过的结点形成一条路径.(注意: 在返回值的list中,数组长度 ...
- 高性能mysql 第1,2,3章。
一: 第一章 1:使用事务 start transaction; select * from t1; commit; 2:查看事务状态 mysql> show variables like 'a ...
- [LeetCode] 804. Unique Morse Code Words_Easy tag: Hash Table
International Morse Code defines a standard encoding where each letter is mapped to a series of dots ...