Thinkphp+Ajax异步请求顺序问题

浏览:598 发布日期:2017/11/21 分类:求助交流 关键字: thinkphp ajax
public function ajax1(){
sleep(5);
echo 1;
}

public function ajax2(){
sleep(1);
echo 2;
}

public function talk(){
$this->display();
}

--------------------------------------------------------------------------------

<!DOCTYPE html>
<html>
<head>
<title></title>
<script type="text/javascript" src="__ROOT__/public/js/jquery.js"></script>
<script type="text/javascript" src="__ROOT__/public/layer/layer.js"></script>

<script type="text/javascript">

$(function(){

$('#1').click(function(){
$.ajax({
url:'/tp/index/ajax1',
type:'post',
success:function(e){
layer.msg(e);
}
})
})

$('#2').click(function(){
$.ajax({
url:'/tp/index/ajax2',
type:'post',
success:function(e){
layer.msg(e);
}
})
})
})

</script>
</head>
<body>

<input type="button" value="1" id="1">
<input type="button" value="2" id="2">


</body>
</html>

Thinkphp3.23

现在想在一个页面实现两个ajax请求,但是发现都是执行完一个ajax之后,才会开始执行另外一个,不是同时开始执行才对的吗

执行时间是ajax1是5s,ajax2是6s
最佳答案
评论( 相关
后面还有条评论,点击查看>>