没有回应jquery-mockjax [英] No response with jquery-mockjax
本文介绍了没有回应jquery-mockjax的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试使用jquery-mockjax库来模拟ajax,但我看不到任何响应。
我的代码如下:
I am trying to use jquery-mockjax library to mock ajax, but I cannot see any response. My code is as follow :
<!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>
我有什么遗漏?
推荐答案
我遇到了同样的问题,正在敲打我的头半小时,大喊为什么?
I had this same problem and was banging my head for half an hour, and shouting "why?"
尝试降级jQuery到1。*
Try downgrading jQuery to 1.*
这篇关于没有回应jquery-mockjax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文