<script type="text/javascript"> $('#tab-1').click(function(){ var data = Ajaxs("test.php"); alert(data); }); function Ajaxs($url,$urlType="get",$data=''){ $.ajax({ type: $urlType, url: $url, data:$data, beforeSend: function(){ }, success: function(data){ alert(data); return data; }, error: function(){ alert('请求失败'); } }); } </script>
为什么 success :alert(data)可以将ajax返回的结果打印出来,而return data 会返回 undefined
pardon110