当参数是函数,在ajax的回调函数中调用该参数,那么当调用函数时,ajax中的的函数
对象参数,相当于是函数名
代码示例:
<script>
function https(url,callback){
$.ajax({
url:url,
type:'get',
dataType:'json',
success:function(res){
//给传入的函数传参
callback(res);
}
})
}
//调用函数,并将参数传回的数据,作为参数传给ajax中的回调函数
https('6.php',function(res){console.log(res)});
</script>