Is sending data to a server via a script tag an outdated paradigm?
Posted
by
KingOfHypocrites
on Programmers
See other posts from Programmers
or by KingOfHypocrites
Published on 2013-11-08T17:57:45Z
Indexed on
2013/11/08
22:14 UTC
Read the original article
Hit count: 199
I inherited some old javascript code for a website tracker that submits data to the server using a script url:
var src = "http://domain.zzz/log/method?value1=x&value2=x"
var e = document.createElement('script');
e.src = src;
I guess the idea was that cross domain requests didn't haven't to be enabled perhaps. Also it was written back in 2005. I'm not sure how well XmlHttpRequests were supported at the time. Anyone could stick this on their website and send data to our server for logging and it ideally would work in most any browser with javascript.
The main limitation is all the server can do is send back javascript code and each request has to wait for a response from the server (in the form of a generic acknowledgement javascript method call) to know it was received, then it sends the next.
I can't find anyone doing this online or any metrics as to whether this faster or more secure than XmlHttpRequests. I don't know if this is just an old way of doing things or it's still the best way to send data to the server when you are mostly trying to send data one way and you need the best performance possible.
So in summary is sending data via a script tag an outdated paradigm? Should I abandon in favor of using XmlHttpRequsts?
© Programmers or respective owner