views:

545

answers:

2

So I'm reading The Art & Science of Javscript, which is a good book, and it has a good section on JSONP. I've been reading all I can about it today, and even looking through every question here on StackOverflow. JSONP is a great idea, but it only seems to resolve the "Same Origin Problem" for getting data, but doesn't address it for changing data.

Did I just miss all the blogs that talked about this, or is JSONP not the solution I was hoping for?

+3  A: 

JSONP results in a SCRIPT tag being generated to another server with any parameters that might be required as a GET request. e.g.

<script src="http://myserver.com/getjson?customer=232&amp;callback=jsonp543354" type="text/javascript">
</script>

There is technically nothing to stop this sort of request altering data on the server, e.g. specifying newName=Tony. Your response could then be whether the update succeeded or not. You will be limited by whatever you can fit on a querystring. If you are going with this approach add some random element as a parameter so that proxy's won't cache it.

Some people may consider this goes against the way GET's are supposed to work i.e. they shouldn't cause data to change.

Duncan
A: 

Yes, and honestly I would like to stick to that paradigm. However, I might bend the rule and say that, requests which do not alter/deal with CRUCIAL data will be accessible via GET calls... hm...

For instance, I am building a shopping cart system, and I think that allowing the adding/removing/etc of items to/from a cart could very easily be exposed via GETs, since even though you can change data, you cannot do anything critical with it. If someone maliciously added 1,000 flatscreen monitors to your shopping cart, there would be at least one verification step that would NOT be vulnerable to any attacks (a standard ASP.NET page at that point, with verification and all that jazz).

Is this a good/workable solution in anyones' opinion?

goldenratio