From: Garrett Smith on 9 Jan 2010 01:49 kangax wrote: > On 1/7/10 7:00 PM, FAQ server wrote: >> ----------------------------------------------------------------------- >> FAQ Topic - How do I run a server side script? >> ----------------------------------------------------------------------- >> >> You trigger a server-side script by sending an HTTP request. >> This can be acheived by setting the ` src ` of an ` img `, fix spelling: achieved. >> ` Image `, ` frame `, or ` iframe `, >> or by using XHR. >> or by using `XMLHttpRequest`, where supported, tested as: var IS_NATIVE_XHR = typeof XMLHttpRequest != "undefined"; >> An image will also >> "swallow" the data sent back by the server, so that they will >> not be visible anywhere. >> >> var dummyImage = new Image(); >> dummyImage.src = "scriptURL.asp?param=" + varName; >> >> Mozilla, Opera 7.6+, Safari 1.2+, and Windows IE 7 > > Wouldn't it make sense to also mention that IE7 (and 8) only provide > `XMLHttpRequest` when corresponding feature is enabled in browser? > Where supported. [[HasProperty]] test (`in` operator) fails in IE. -- Garrett comp.lang.javascript FAQ: http://jibbering.com/faq/
From: kangax on 9 Jan 2010 02:12 On 1/9/10 1:49 AM, Garrett Smith wrote: > kangax wrote: >> On 1/7/10 7:00 PM, FAQ server wrote: >>> ----------------------------------------------------------------------- >>> FAQ Topic - How do I run a server side script? >>> ----------------------------------------------------------------------- [...] >>> An image will also >>> "swallow" the data sent back by the server, so that they will >>> not be visible anywhere. >>> >>> var dummyImage = new Image(); >>> dummyImage.src = "scriptURL.asp?param=" + varName; >>> >>> Mozilla, Opera 7.6+, Safari 1.2+, and Windows IE 7 >> >> Wouldn't it make sense to also mention that IE7 (and 8) only provide >> `XMLHttpRequest` when corresponding feature is enabled in browser? >> > > Where supported. [[HasProperty]] test (`in` operator) fails in IE. Yes, `in` can be misleading. <http://twitter.com/kangax/status/7447765023> -- kangax
From: Jorge on 9 Jan 2010 05:16 On Jan 9, 6:45 am, kangax <kan...(a)gmail.com> wrote: > On 1/7/10 10:11 PM, Jorge wrote: > > > On Jan 8, 1:00 am, "FAQ server"<javascr...(a)dotinternet.be> wrote: > >> XMLHttpRequest ` can send HTTP requests to > >> the server (...) > > > I would like to propose ~ this: > > > XMLHttpRequest can send HTTP requests only to the same domain and port > > from where current page came from (as seen in the current > > location.host and location.port), and using the same protocol (the > > current location.protocol). > > Not if environment supports Cross-Origin Resource Sharing standard > (currently draft http://www.w3.org/TR/cors/), and all prerequisites > are met (e.g. server response' headers indicate request allowance). Yep, what about something ~ like this: In some (newer as of 2009) browsers, cross-domain XMLHttpRequests are allowed, but that's just half of the story as for a cross-domain XHR to complete successfully the target domain's server must have been configured to cooperate by expressly setting a predefined header in the response. ? > Firefox 3.5+ does (https://developer.mozilla.org/En/HTTP_Access_Control). Safari >= 4 does: http://www.google.com/search?q=%22Cross-Site+Requests%22+site:developer.apple.com -- Jorge.
From: kangax on 9 Jan 2010 15:36 On 1/9/10 5:16 AM, Jorge wrote: > On Jan 9, 6:45 am, kangax<kan...(a)gmail.com> wrote: >> On 1/7/10 10:11 PM, Jorge wrote: >> >>> On Jan 8, 1:00 am, "FAQ server"<javascr...(a)dotinternet.be> wrote: >>>> XMLHttpRequest ` can send HTTP requests to >>>> the server (...) >> >>> I would like to propose ~ this: >> >>> XMLHttpRequest can send HTTP requests only to the same domain and port >>> from where current page came from (as seen in the current >>> location.host and location.port), and using the same protocol (the >>> current location.protocol). >> >> Not if environment supports Cross-Origin Resource Sharing standard >> (currently draft �http://www.w3.org/TR/cors/), and all prerequisites >> are met (e.g. server response' headers indicate request allowance). > > Yep, what about something ~ like this: > > In some (newer as of 2009) browsers, cross-domain XMLHttpRequests are > allowed, but that's just half of the story as for a cross-domain XHR > to complete successfully the target domain's server must have been > configured to cooperate by expressly setting a predefined header in > the response. > > ? Sounds alright. > >> Firefox 3.5+ does (https://developer.mozilla.org/En/HTTP_Access_Control). > > Safari>= 4 does: > http://www.google.com/search?q=%22Cross-Site+Requests%22+site:developer.apple.com Ah, thanks, good to know (<http://developer.apple.com/safari/library/documentation/AppleApplications/Conceptual/SafariJSProgTopics/Articles/XHR.html#//apple_ref/doc/uid/TP40006227-SW8>) <-- that's one monstrous URL they've got there. There's also XDomainRequest in IE (<http://msdn.microsoft.com/en-us/library/dd573303%28VS.85%29.aspx>). I haven't looked into it yet. -- kangax
From: Thomas 'PointedEars' Lahn on 9 Jan 2010 18:16 Jorge wrote: > On Jan 9, 6:45 am, kangax <kan...(a)gmail.com> wrote: >> On 1/7/10 10:11 PM, Jorge wrote: >> > On Jan 8, 1:00 am, "FAQ server"<javascr...(a)dotinternet.be> wrote: >> >> XMLHttpRequest ` can send HTTP requests to >> >> the server (...) >> > >> > I would like to propose ~ this: >> > >> > XMLHttpRequest can send HTTP requests only to the same domain and port >> > from where current page came from (as seen in the current >> > location.host and location.port), and using the same protocol (the >> > current location.protocol). >> >> Not if environment supports Cross-Origin Resource Sharing standard >> (currently draft —http://www.w3.org/TR/cors/), and all prerequisites >> are met (e.g. server response' headers indicate request allowance). > > Yep, what about something ~ like this: > > In some (newer as of 2009) browsers, cross-domain XMLHttpRequests are > allowed, but that's just half of the story as for a cross-domain XHR > to complete successfully the target domain's server must have been > configured to cooperate by expressly setting a predefined header in > the response. > > ? Informal language like colloquialisms and idioms should scarcely be used in the FAQ, if that; a FAQ should mostly be written in a formal, no-nonsense, matter-of-fact style so as not to confuse the individuals who would otherwise ask the corresponding questions in the newsgroup (or so it is hoped). PointedEars -- Use any version of Microsoft Frontpage to create your site. (This won't prevent people from viewing your source, but no one will want to steal it.) -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 Prev: Difference between WScript and CScript Next: dynamically adding filter +IE6 |