jQuery的1.5模拟阿贾克斯 [英] jquery 1.5 mock ajax
问题描述
在jQuery的1.5,什么是嘲讽Ajax请求的推荐方法?难道它使用AJAX扩展传输方式? http://api.jquery.com/extending-ajax/#Transports
In jquery 1.5, what is the recommend approach for mocking ajax requests? Is it to use the ajax extension transports? http://api.jquery.com/extending-ajax/#Transports
推荐答案
您是否尝试过延长 $。阿贾克斯
与1.5的更新,并找出如果你可以调用 .resolve
在 jqXHR
。
Have you tried extending $.ajax
with the 1.5 update and finding out if you can call .resolve
on the jqXHR
.
只要你得到它不会删除 .promise
只读延迟的对象,你应该能够伪造一个完成Ajax请求的。
As long as you get it to not remove the .promise
read-only Deferred object you should be able to fake a completion of the ajax request.
替代,你永远可以模拟出一个的node.js
服务器。
Alternative you can always just mock out a node.js
server.
任何地方,你可以连接到并获得 jqXHR
对象,你也许可以称之为 .resolve
它与模拟paramaters。
Anywhere you can hook into and get the jqXHR
object you might be able to call .resolve
on it with the mock paramaters.
这篇关于jQuery的1.5模拟阿贾克斯的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!