Path: csiph.com!au2pb.net!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder1.news.weretis.net!news.solani.org!.POSTED!not-for-mail From: "Christoph M. Becker" Newsgroups: comp.lang.javascript Subject: Re: Can AJAX request a .js file? Date: Thu, 3 Sep 2015 00:11:23 +0200 Organization: solani.org Lines: 20 Message-ID: References: <9ba8b186-10e2-4510-b456-8d38608db644@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: solani.org 1441231878 10436 eJwNwokRACEIBLCWUFjEcnjc/ku4mwTqy/uYww0EVQKPPbOD1dfs6Dgjj4C9ONwvk2TeX0l9NqgSuA== (2 Sep 2015 22:11:18 GMT) X-Complaints-To: abuse@news.solani.org NNTP-Posting-Date: Wed, 2 Sep 2015 22:11:18 +0000 (UTC) User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0 X-User-ID: eJwFwQkBwDAIA0BLBAK0cnhW/xJ25xaISYYH/fk7xQ/StnkNs6I4KrMKr25k7RYFYtZ66ckfE8sQdQ== In-Reply-To: <9ba8b186-10e2-4510-b456-8d38608db644@googlegroups.com> Cancel-Lock: sha1:MZgHokEMRttNODfhUCfUkdcEmS4= X-NNTP-Posting-Host: eJwFwQERACAIA8BKzMGgjuDRP4L/QUGTrpDHxu52GiEjI33g4aXTxPBpa85D1aKBO9dwPgSlEFY= Xref: csiph.com comp.lang.javascript:28602 Jay Braun wrote: > Can I use XMLHttpRequest to request a .js file, e.g.: > > request.open('GET', latest.js); Basically, yes. Of course you have to put `latest.js` in quotes (probably just a typo), and SOP applies as usual. However, you would have to evaluate the script manually (i.e. the host won't do it automatically). You may consider letting the host environment do the work for you by dynamically adding a respective script element, instead. You can circumvent client side caching by adding a unique query string to the URI. IIRC, the FAQ[1] elaborates on this. [1] -- Christoph M. Becker