Comments (7)
Hi Zach,
Can you submit a pull request with a failing test for this?
- jd
from amplify.
I didn't have time to do this, but here's the workaround I used:
amplify.request.cache.jsonpToLocalStorage = function(resource, settings, ajaxSettings, xhr)
{
var ajaxSettingsCopy = $.extend({}, ajaxSettings);
ajaxSettingsCopy.url = ajaxSettingsCopy.url.replace(/\&?callback=[^&]*\&?/gi, '');
return amplify.request.cache.localStorage(resource, settings, ajaxSettingsCopy, xhr);
};
and then use the jsonpToLocalStorage
type instead of localStorage
.
from amplify.
I'm having the same issue (I think). In making a jsonp request with ?callback=? a unique callback id is generated by jQuery, which creates a unique cache name property ("myurl.com?callback=111111") based on the entire url including the callback id.
On a follow on request a new unique callback id is generated, thus a new cache name (myurl.com?callback=222222") and thus the earlier cache is ignored and a new http request is made instead.
from amplify.
This is still and issue. I am about to record about this feature for my 1st Pluralsight course due on Saturday. Anyone have a pull request for it?
I'm a little swamped at the moment. I did do a PR for mockjax yesterday, but don't think I'll get around to a PR on this one.
from amplify.
I was looking into it this morning and since jQuery supports a number of options, the fix will have to account for the following:
- Pay attention to the
dataType
, and only attempt this fix if its set tojsonp
- Correctly look to the
jsonp
option to see if we should look forcallback=
or something else. - Look to
jsonpCallback
to see the name of callback to remove from the url - Make sure
cache
is set totrue
on AJAX Settings, else a_=TIMESTAMP
will also be added to the URL
Number 4 should already be handled due to the way amplify will just pass on the cache setting to $.ajax
and it will not be false
in the case of someone wanting to cache a JSONP request.
from amplify.
Was looking into this one for a few minutes and found one interesting thing to note: jQuery 1.8+ tries to safely reuse the jsonp callback names whenever possible. So, in some simple examples to reproduce this issue, the caching worked properly as the URL does not change (it does each time prior to 1.8).
from amplify.
I have created a pull request to fix this issue.
from amplify.
Related Issues (20)
- Amplify 1.1.2 Uncaught TypeError in new Chrome
- Race condition in core.js publish method HOT 5
- Add browser support documentation [was: "IE8 support"] HOT 1
- amplify.js incompatible with FormData
- losing the data in local storage that I set on a HTTP page when I move to a HTTPS page HOT 1
- Subscribe to event groups (namespaces)
- is amplify still being developed? HOT 5
- null being passed to handleResponse on error instead of _xhr HOT 1
- Any plan to support chrome.storage in the future?
- Not an issue, a suggestion... for pubsub HOT 1
- support for commonjs HOT 1
- amplify.store() examples in the docs is not working HOT 1
- ajax request types are taking longer than default jquery ajax calls
- need clear all subscription method
- Publish core as a separate module
- Offline DB Support HOT 1
- Provide a 'baseURL' option HOT 1
- userData domain level persistance not working HOT 1
- Publish/Subscribe across iframes HOT 4
- BUG: amplify.request on IE 9 not work HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amplify.