标签:body head javascrip oct lang htm click tps pos
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<a href="javascript:void(0);" id="send">test</a>
</body>
<!--引用外部jquery资源-->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script>
//ajax中调用回调函数
//success属性仅需要对函数的引用,并将数据作为参数传递给此函数
$(‘#send‘).click(function(){
$.ajax({
type: "post",
url: "/ajax.php",
dataType: "json",
success : handleData //载入成功时执行的回调函数
});
});
function handleData(data){ //执行回调函数
//do some thing
alert(data.data);
alert(data.status);
}
</script>
</html>
标签:body head javascrip oct lang htm click tps pos
原文地址:http://www.cnblogs.com/719907411hl/p/7454561.html