You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
we should definitely look at how to port jquery's getJSON() method because it's just a very simple and easy way to obtain information from another website, without messing around building your own script handler.
I believe there was an attempt to make a <script> transport for prototype, to a degree, it worked, however it lacked the ability to use a callback when the contents of the tag were finally loaded (when usually you'd expect an onload event, there is none, so the callback method for JSONP allows you to insert a callback so when it executes, it's because the contents has loaded (otherwise the callbac wouldnt run either). The sample implementation that I tried was this:
but it is not foolproof and with some work, it could provide us with a
The security problems this causes are merely in the hands of the developer if they should choose to use it, like in jquery, it's a gun, you point it at your website, or at your head, where you pull the trigger, is up to you. But I think this feature would really rock.</p>
I think such functionality is definitely useful. The content becomes more dynamic and "mashups" - more popular. Having a robust way of fetching JSON from remote hosts is a must.
Feel free to submit patch/tests.
I'm marking it as enhancement for future releases.
I've just added a plugin for Prototype to use flXHR (http://flxhr.flensed.com) for cross-domain Ajax. Since flXHR is completely the same API as native XHR, it just plugs right in and works exactly like regular Ajax calls -- no other code changes needed.
Here's the Prototype plugin, called flXHRproxy: http://flxhr.flensed.com/prototype.php
Since it's just like XHR, it can do JSON, JSONP, XML, HTML, text, even binary as requests and responses. And all with cross-domain Ajax that just couldn't get any simpler.
@Juriy: Is the core team still interested in adding this to Prototype? If so, would this be a suitable solution? It's based on a gist by Tobie Langel with some added functionality for various phases of the life cycle, including onFailure. http://gist.github.com/147172
Better testing is needed, as well as some input as to whether this should hook into the Ajax.Responders callbacks.
I've also got another project for doing simple JSON-P cross-domain calls via the XHR API interface: jXHR http://mulletxhr.com
It works just like the native XHR object, but uses JSON-P style script tags to make the calls (so it doesn't rely on flash like flXHR does). It also adds basic error handling to the calls.
ronin-24025 (at lighthouseapp)
September 9th, 2009 @ 04:28 PM
I did a ton of research on cross-domain ajax: flash-based techniques, JSONP, proxying techniques, Kris Zyp's WindowNameRequest technique. Executive summary:
FLASH:
Proprietary.
JSONP:
Requires support from server. Limits POST request (if supported) representation size to 4kb.
Proxy:
Requires proxy server.
WindowNameRequest:
Requires support from server. Limits POST request (if supported) representation size to 10mb.
A primitive and more complex version of WindowNameRequest was used by Google last year. Kris Zyp's version subsequently improved and simplified it: http://www.sitepen.com/blog/2008/07/22/windowname-transport/
Hey... so what's the status on the Ajax.JASONRequest.??
The whole idea of JASONP looks more like a workaround, but alas there is not other easier way.
Clearly there is a need for this and I would request to take it on priority. As mentioned above , JQuery already one.
I was interested in making a traffic monitoring mashup through twitter messages, and google maps api. After going through Crockford's JS tutorial videos, really wanted to make it javascript, thereby moving everything into a nifty javascript code which in turn could be pasted by anyone in his html page.
Unfortunately there aren't many javascript libraries for twitter. I have been working with Prototype for past few years, so being a faithful, wanted to give it a try first. But looks like the cross-domain restriction is a big roadblock for mash-up in a client-side processing environment.
And I think we should also work to make a twitter library through Prototype. But before that we really need some kind of JASONP implementation.
Regards
-AK
Activity
jwestbrook commentedon May 7, 2014
Juriy Zaytsev
September 10th, 2008 @ 03:46 AM
I think such functionality is definitely useful. The content becomes more dynamic and "mashups" - more popular. Having a robust way of fetching JSON from remote hosts is a must.
Feel free to submit patch/tests.
I'm marking it as enhancement for future releases.
jwestbrook commentedon May 7, 2014
Juriy Zaytsev
October 7th, 2008 @ 06:22 AM
I was experimenting with this some time ago http://github.com/kangax/protolicious/tree/master/get_json.js
Does anyone else have a working example? Are there any caveats to watch for?
jwestbrook commentedon May 7, 2014
Kyle Simpson
May 22nd, 2009 @ 06:12 PM
I've just added a plugin for Prototype to use flXHR (http://flxhr.flensed.com) for cross-domain Ajax. Since flXHR is completely the same API as native XHR, it just plugs right in and works exactly like regular Ajax calls -- no other code changes needed.
Here's the Prototype plugin, called flXHRproxy: http://flxhr.flensed.com/prototype.php
Since it's just like XHR, it can do JSON, JSONP, XML, HTML, text, even binary as requests and responses. And all with cross-domain Ajax that just couldn't get any simpler.
jwestbrook commentedon May 7, 2014
Valery
June 18th, 2009 @ 08:20 PM
friends, so, there is still no JSONP for PrototypeJS?..
@kyle, did I correctly understand, that your solution needs Flash?
jwestbrook commentedon May 7, 2014
Juriy Zaytsev
June 22nd, 2009 @ 07:20 PM
@valery Did the script from "protolicious" work for you?
jwestbrook commentedon May 7, 2014
Dan Dean
July 15th, 2009 @ 12:32 AM
@Juriy: Is the core team still interested in adding this to Prototype? If so, would this be a suitable solution? It's based on a gist by Tobie Langel with some added functionality for various phases of the life cycle, including onFailure.
http://gist.github.com/147172
Better testing is needed, as well as some input as to whether this should hook into the Ajax.Responders callbacks.
jwestbrook commentedon May 7, 2014
Dan Dean
July 15th, 2009 @ 05:15 AM
I've added this feature to Github along with documentation and explanation:
http://github.com/dandean/Ajax.JSONRequest
jwestbrook commentedon May 7, 2014
Kyle Simpson
September 8th, 2009 @ 05:05 AM
I've also got another project for doing simple JSON-P cross-domain calls via the XHR API interface: jXHR http://mulletxhr.com
It works just like the native XHR object, but uses JSON-P style script tags to make the calls (so it doesn't rely on flash like flXHR does). It also adds basic error handling to the calls.
jwestbrook commentedon May 7, 2014
ronin-24025 (at lighthouseapp)
September 9th, 2009 @ 04:28 PM
I did a ton of research on cross-domain ajax: flash-based techniques, JSONP, proxying techniques, Kris Zyp's WindowNameRequest technique. Executive summary:
FLASH:
Proprietary.
JSONP:
Requires support from server. Limits POST request (if supported) representation size to 4kb.
Proxy:
Requires proxy server.
WindowNameRequest:
Requires support from server. Limits POST request (if supported) representation size to 10mb.
A primitive and more complex version of WindowNameRequest was used by Google last year. Kris Zyp's version subsequently improved and simplified it: http://www.sitepen.com/blog/2008/07/22/windowname-transport/
jwestbrook commentedon May 7, 2014
Amit Kumar
June 10th, 2010 @ 10:22 PM
Hey... so what's the status on the Ajax.JASONRequest.??
The whole idea of JASONP looks more like a workaround, but alas there is not other easier way.
Clearly there is a need for this and I would request to take it on priority. As mentioned above , JQuery already one.
I was interested in making a traffic monitoring mashup through twitter messages, and google maps api. After going through Crockford's JS tutorial videos, really wanted to make it javascript, thereby moving everything into a nifty javascript code which in turn could be pasted by anyone in his html page.
Unfortunately there aren't many javascript libraries for twitter. I have been working with Prototype for past few years, so being a faithful, wanted to give it a try first. But looks like the cross-domain restriction is a big roadblock for mash-up in a client-side processing environment.
And I think we should also work to make a twitter library through Prototype. But before that we really need some kind of JASONP implementation.
Regards
-AK
jwestbrook commentedon May 7, 2014
Jason Laumeister
December 8th, 2010 @ 02:18 AM
I've had success with prototype 1.6.1 and Dan Dean's jsonp implementation here: https://github.com/dandean/Ajax.JSONRequest
Dan Dean's implementation is < 120 lines of javascript (< 3.9k).
jsonp is a necessary work-around for cross-domain restrictions that would otherwise prohibit a page from making an ajax call to a third party server. A real-world example would be an online game that includes ads in an DHTML popup from a third party ad network as seen in the following prototype/jsonp example.
ajax/jsonp example:
jsonp example: http://super.kitnmedia.com/publisher_api/adk_demo/prototype_ad_demo
implementation docs: http://cdn.superrewards-offers.com/docs/adk_overlay_api.html#igo_in...
source code: http://cdn.superrewards-offers.com/js/tools/interstitial/adk.inters...
This example relies on Dan Dean's jsonp implementation as described in the implementation docs.
jwestbrook commentedon May 7, 2014
Alexander Vassbotn Røyne
February 3rd, 2011 @ 09:07 AM
What is the status on this issue?