Originally Posted by and0rsk
I was wondering if someone could clarify for me the cases you would use XML HTTP Request over a JSONP. From my understanding, they both can retrieve files but the XHR has the same origin policy which JSONP doesn't. It also appears that JSONP is much simpiler to implement over XHR as it only requires a script tag while XHR has a series of tags. So...Maybe i just don't understand the XHR or the JSONP. Could someone clarify these 3 questions for me:
1) The purpose of XHR and JSONP.
2) The use cases for XHR and JSONP
3) When you program, how often/when do you personally tend to use XHR over JSONP.
Both provide a way to retrieve information from the server.
Both XHR2 and JSONP can retrieve from other domains - only the origiinal XHR has a same domain policy.
JSONP can only retrieve data in one specifiic format. XHR can retrieve in any format including XML and JSON and even plain text.
XHR can retrieve static XML files without requiring any server side processing.
XHR triggers an even when the data is returned and can then perform error handling - JSONP simply runs if it fis successfully retrieved and does nothing if the request fails.
Helping others to solve their computer problem at http://www.felgall.com/