1
我想用jquery-mockjax库来模拟ajax,但我看不到任何响应。 我的代码如下:jquery-mockjax没有响应
<!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>
有什么我失踪?
我找到了原因。我使用的jquery版本> 2.0 – Ray 2013-05-07 06:11:11
将jquery版本降级到1.9.1后,它的工作原理! – Ray 2013-05-07 06:11:43
请发表您的答案作为答案,而不是评论。另外,你正在使用哪个版本的mockjax? – Flimzy 2014-06-06 02:08:13