Posts

Showing posts with the label request

How To JSONP A Static File

Update I have discussed this object a part and I agree that the url could be used as unique id as well. In this case the server should use the static url as unique id: StaticJSONP.notify("http://cdn.com/static/article/id.js",{..data..}); So that on client side we can use the simplified signature: StaticJSONP.request( "http://cdn.com/static/article/id.js", function (uid, data) { } ); The callback will receive the uid in any case so that we can create a single callback and handle behaviors accordingly. The script has been updated in order to accept 2 arguments but, if necessary, the explicit unique id is still supported. Under the list of " incomplete and never posted stuff " I found this article which has been eventually reviewed. I know it's " not that compact " but I really would like you to follow the reason I thought about a solution to a not so common, but quite nasty, problem. Back in 2001, my early attempts to include cal...

Ajax or JavaScript sub domain request

Some time we could have a situation like this one: a site in a sub domain, called http://a.test.com another site in another sub domain, called http://b.test.com of course, a generic main site, called http://test.com A common problem between one or more sub domains, is the possibility to use, or call, scripts in the main domain, because of security restrictions. The simplest solution is to force, in the client side, the document.domain, specifying the common one, i.e. dcument.domain = "test.com"; In this way you can add, for example, an iframe, and read its content, or use parent window object from the iframe that points, for example, to http://test.com There are different reasons to do it, and one of them, is the ability to share a global, or common, space, between every sub domain, performing Ajax requests or whatever else we need. This object, saved in http://test.com, and loaded by every other sub domain, like "a" or "b", could solve in a really simple ...