Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #16716 > unrolled thread

ajax and jsonp and mobile

Started byAndrew Poulos <ap_prog@hotmail.com>
First post2012-10-19 07:57 +1100
Last post2012-10-24 01:45 +0100
Articles 3 — 3 participants

Back to article view | Back to comp.lang.javascript


Contents

  ajax and jsonp and mobile Andrew Poulos <ap_prog@hotmail.com> - 2012-10-19 07:57 +1100
    Re: ajax and jsonp and mobile Cezary Tomczyk <cezary.tomczyk@gmail.com> - 2012-10-19 00:23 +0200
    Re: ajax and jsonp and mobile Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2012-10-24 01:45 +0100

#16716 — ajax and jsonp and mobile

FromAndrew Poulos <ap_prog@hotmail.com>
Date2012-10-19 07:57 +1100
Subjectajax and jsonp and mobile
Message-ID<UYmdnaH3qI_a8B3NnZ2dnUVZ_tWdnZ2d@westnet.com.au>
AFAIK

AJAX
- not cross domain
- has error handling

JSONP
- cross domain
- no error handling
- insecure
- adds javascript elements to the page

Both can return the same "data" and in my testing I couldn't find any 
real speed differences between the two.

If I'm writing a mobile app in HTML5 which needs to talk with a
web-based database. Is JSONP the only option?

Andrew Poulos

[toc] | [next] | [standalone]


#16719

FromCezary Tomczyk <cezary.tomczyk@gmail.com>
Date2012-10-19 00:23 +0200
Message-ID<k5pvh2$u1g$1@speranza.aioe.org>
In reply to#16716
W dniu 2012-10-18 22:57, Andrew Poulos pisze:
> AFAIK
>
> AJAX
> - not cross domain

Not really, but there is some conditions. See: 
https://developer.mozilla.org/en-US/docs/HTTP_access_control

> - has error handling
>
> JSONP
> - cross domain
> - no error handling

The workaround is to use setTimeout. Not perfect, but personally I don't 
know better way.

> - insecure
> - adds javascript elements to the page

-- 
Cezary Tomczyk
http://www.ctomczyk.pl/

[toc] | [prev] | [next] | [standalone]


#16826

FromThomas 'PointedEars' Lahn <PointedEars@web.de>
Date2012-10-24 01:45 +0100
Message-ID<3451959.NK5rUynJWR@PointedEars.de>
In reply to#16716
Andrew Poulos wrote:

> AFAIK
> 
> AJAX

That is a misnomer which leads to misconceptions.  Forget about it.

> - not cross domain

Not necessarily.  You can allow that now with a header field.  See the other 
answer.

> - has error handling

Not necessarily.  There are errors that cannot be handled.
 
> JSONP
> - cross domain

Not necessarily.  You can forbid that based on the Referer (sic!), but it 
can be circumvented.

> - no error handling

Not necessarily.  You can add error handling.

> - insecure

Not necessarily.  HTTP over SSL/TLS can be used the same as it can with XHR.

> - adds javascript elements to the page

No, it adds `script' elements to an (X)HTML document.  That is where that 
technique is inherently unreliable, because AFAIK there still is no 
(quasi-)standard specifying what is supposed to happen then.  Proper tests 
are pending.
 
> Both can return the same "data"

No.  A script inserted with JSONP can include code that is compiled and 
executed immediately.  A script returned from XHR needs to be 
inserted/evaluated before it is executed.

> and in my testing I couldn't find any real speed differences between the
> two.

Test more.

> If I'm writing a mobile app in HTML5 which needs to talk with a
> web-based database. Is JSONP the only option?

No.


PointedEars
-- 
Danny Goodman's books are out of date and teach practices that are
positively harmful for cross-browser scripting.
  -- Richard Cornford, cljs, <cife6q$253$1$8300dec7@news.demon.co.uk> (2004)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.javascript


csiph-web