我正在尝试使用 jquery-mockjax 库来模拟 ajax,但我看不到任何响应。我的代码如下:
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="components/jquery/jquery.js"></script>
<script src="components/jquery-mockjax/jquery.mockjax.js"></script>
<script>
$(function(){
$.mockjax({
url: '/test/inline',
contentType: "text/json",
responseTime: 0,
responseText: {
say: 'Hello world!'
}
});
$('#btn').click(function(){
$.ajax({
url: '/test/inline',
type: "GET",
dataType: 'json',
success: function(json) {
alert('You said: ' + json.say);
},
complete: function() {
$.mockjaxClear();
alert('completed');
}
});
}
);
});
</script>
</head>
<body>
<button id="btn">Get</button>
</body>
</html>
有什么我想念的吗?