回调函数适用于:
function mySandwich(param1, param2, callback) {
alert('Started eating my sandwich.\n\nIt has: ' + param1 + ', ' + param2);
callback();
}
mySandwich('ham', 'cheese', function() {
alert('Finished eating my sandwich.');
});
在体内标签中。
当我尝试时:
<html>
<head>
<script>
function CallAfterLogin()
{
document.mySandwich('hi',function(send){
alert("finished");
});
}
</script>
</head>
<body>
<button type="button" onclick="CallAfterLogin()">Click Me!</button>
<script>
function mySandwich(param1, callback) {
alert('Started eating my sandwich.\n\nIt has: ' + param1 );
callback();
}
</script>
</body>
</html>
它给出错误:document.mySandwich 未定义。有人可以告诉我问题出在哪里吗?