问题描述
什么是做一个骨干取时,缓存此回调值的正确方法是什么?
已经尝试overiding抓取功能和设置。
What is the correct way to cache this callback value when doing a backbone fetch?Have tried overiding the fetch function and setting
options.cache = true;
但无济于事。
在理想情况下,我们希望继续使用获取,而不是编写自定义的Ajax调用。
下面是被所附的回调参数的一个例子。我需要这是相同的返回值每一次,即所以它作为一个高速缓存。
Ideally we want to continue using fetch, and not write a custom ajax call.The below is an example of the callback parameter that is being appended. I need this to be the same return value each time, i.e so it's acting as a cache.
&callback=jQuery1111042059096531011164_1421344480838&_=1421344480840
如果更详细需要请让我知道,
If more detail is needed please let me know,
非常感谢。
推荐答案
仅供参考。
这似乎至今已工作是没有覆盖的获取,但覆盖℃的字符串作为jsonPCallback同步和硬$ C $,如下面的解决方案。
The solution that appears so far to have worked was to not override the fetch but override the sync and hardcode a string as the jsonPCallback such as below.
sync: function(method, model, options){
options.dataType = this.SYNC_METHOD;
options.cache = true;
options.jsonp = 'callback';
options.jsonpCallback = "onNowCallback";
return Backbone.sync(method, model, options);}
这篇关于做主干时缓存JSONP回调参数取的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!