Day: December 28, 2015

JQuery: 使用Ajax赋值给全局变量失败异常的解决方法,ajaxSetup, jquery ajax global

我们在用JQuery的Ajax从后台提取数据后想把它赋值给全局变量,但是却怎么都赋不进,为什么呢? 原因其实很简单,我们用的Ajax是异步操作,也就是说在你赋值的时候数据还没提取出来,你当然赋不进去,所以只要改成同步操作就行~ 方法1:先设置同步在进行Ajax操作 //在全局或某个需要的函数内设置Ajax异步为false,也就是同步 $.ajaxSetup({ async :false}); //然后再进行你的Ajax操作 $.post(地址,参数,function(data, status){if(status =="success"){//赋值给全局变量}else{ alert("wrong");}}); 方法2… Read More

Bootstrap 3: 监听弹出窗口关闭/打开事件 How to handle the modal closing event in Twitter Bootstrap?

Updated for Bootstrap 3 Bootstrap 3 documentation refers two events you can use hide.bs.modal: This event is fired immediately when the hide instance method has been called. hidden.bs.modal: This event is fired when the modal has finished being hidden from the user (will wait for CSS transitions to complete). And provides an example on how to use them: $('…