Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.javascript > #8605
| Path | csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!newsfeed.straub-nv.de!noris.net!news.teledata-fn.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <2567734.rclGbaif12@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <cljs@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Thu, 24 Nov 2011 21:27:43 +0100 |
| User-Agent | KNode/4.4.11 |
| Content-Transfer-Encoding | 8Bit |
| Subject | Re: Read url into a string? |
| Newsgroups | comp.lang.javascript |
| Followup-To | comp.lang.javascript |
| References | <a0faab1d-920c-4d58-bb9f-b382b0b4ce38@w3g2000vbw.googlegroups.com> <pmuqc7t8p6ees0qo6sh484mc2o7jvv4afj@4ax.com> <jajvki$fvb$1@sunce.iskon.hr> |
| Supersedes | <1935564.nKmheAe9J7@PointedEars.de> |
| MIME-Version | 1.0 |
| Lines | 43 |
| NNTP-Posting-Date | 24 Nov 2011 21:27:43 CET |
| NNTP-Posting-Host | a6716715.newsspool1.arcor-online.net |
| X-Trace | DXC=Cl\dXXN1_[g[F<50eo:0knic==]BZ:afn4Fo<]lROoRa<`=YMgDjhgb`W;:Ca2SK7dDZm8W4\YJNl;?f@h5gMfble<YaZJ]Je?ifUAnSTm;2kl |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | x330-a1.tempe.blueboxinc.net comp.lang.javascript:8605 |
Followups directed to: comp.lang.javascript
Show key headers only | View raw
Zlatko Đurić wrote:
> function getJSONfromUrl(url) {
> if (window.XMLHttpRequest) {
> xhr=new XMLHttpRequest();
> } else {
> xhr=new ActiveXObject("Microsoft.XMLHTTP");
> }
> xhr.open("GET",url,false);
> xhr.send();
> return xhr.responseText;
> }
>
> ?
The flaws of this code are many:
- Bogus XHR() feature test
- `xhr' not declared a variable
- Missing XHR() exception handling
- Missing ActiveXObject feature test
- Missing XMLHTTP selection
- Missing ActiveXObject() exception handling
- Missing non-XHR()-non-MSXML branch
- Unnecessary synchronous request blocking the client window/tab
- Missing send() argument
- Missing status check
- Insufficient code style
So it is neither safe nor compatible or user-friendly, but it might suffice
for a first dry run. `url' cannot be any URI though, as the Same Origin
Policy would prevent cross-protocol/domain/port access unless the owner of
the other site explicitly allowed it.
<https://developer.mozilla.org/En/HTTP_access_control>
PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16
Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Read url into a string? SpreadTooThin <bjobrien62@gmail.com> - 2011-11-23 14:09 -0800
Re: Read url into a string? Gene Wirchenko <genew@ocis.net> - 2011-11-23 15:00 -0800
Re: Read url into a string? SpreadTooThin <bjobrien62@gmail.com> - 2011-11-23 15:28 -0800
Re: Read url into a string? Zlatko Đurić <zladuric@gmail.com> - 2011-11-24 00:29 +0100
Re: Read url into a string? SpreadTooThin <bjobrien62@gmail.com> - 2011-11-23 15:34 -0800
Re: Read url into a string? SpreadTooThin <bjobrien62@gmail.com> - 2011-11-23 15:37 -0800
Re: Read url into a string? SpreadTooThin <bjobrien62@gmail.com> - 2011-11-23 16:35 -0800
Re: Read url into a string? Scott Sauyet <scott.sauyet@gmail.com> - 2011-11-23 18:02 -0800
Re: Read url into a string? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-24 21:27 +0100
Re: Read url into a string? Zlatko Đurić <zladuric@gmail.com> - 2011-11-24 22:13 +0100
Re: Read url into a string? Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2011-11-24 22:31 +0100
Re: Read url into a string? Zlatko Đurić <zladuric@gmail.com> - 2011-11-24 23:08 +0100
Re: Read url into a string? Arno Welzel <usenet@arnowelzel.de> - 2011-11-25 15:59 +0100
Re: Read url into a string? "Evertjan." <test@abc.invalid> - 2011-11-26 13:44 -0400
csiph-web