JavaScript Requests
There is a need: pass parameters directly to JavaScript.
We can pass parameters through GET, POST, but when passing these parameters, a new page will simply load, i.e. if the browser cache has
some.so/index.php?id=2
and we request
some.so/index.php?id=3
then the server will generate a new page for us, it will not take some.so/index from the cache. php? id = 2 (and will do the right thing).
The same situation is with POST, so to say that you can pass parameters to Javascript using GET and POST methods, of course, but this will not be entirely true. Because parameters are transferred to the server, new content is generated there, and there you can do anything. Although directly taking GET variables from window.location.href, at least somehow the server language re-generates JavaScript every time. and this is just an imitation of JavaScript requests.
However, there is one character in the URL standard that will help us.
This is a pound symbol (#), although some say that it is a symbol of the English currency, but now it does not matter.
The trick is that if there is
some.so/index.php#id:2 in the cache,
we will request
some.so/index.php#idhaps
then the second page will be taken from the cache (which it got after the first request).
So, let's get down to business: after the pound sign in the URL, the following characters are allowed
: _ -.
and any latin characters.
Let the pair (key: value) be separated by a dot; the key itself is separated from the value by a colon, and escaping will be done using underscores.
Thus, if we want to pass 2 parameters, it will look something like this:
some.so/index.php#id:2.par2:dgsdgd
if we want to pass period , colon or non-latin characters, then we do it like this:
some .so / index.php # id: _56_34.par2: _21_20_54
Such JavaScript requests (jR = JavaScript Request) can be distinguished from the usual some.so/index.php#chapter7 links by the presence of a colon (:) after #, because I have never seen anyone put a colon there.
Writing js functions that will be processed by jR is not difficult - we take window.location.href, crop it with regexp, split the string into an array, split the array elements into a key and a value. That's all.
It really works, and really saves traffic, gives fun effects with AJAX, in general, experiment.
Of course, TBL would not be very happy with this use, but still, I think that client-side JavaScript has earned the fact that now it will be able to receive parameters directly for itself. Hurrah!
We can pass parameters through GET, POST, but when passing these parameters, a new page will simply load, i.e. if the browser cache has
some.so/index.php?id=2
and we request
some.so/index.php?id=3
then the server will generate a new page for us, it will not take some.so/index from the cache. php? id = 2 (and will do the right thing).
The same situation is with POST, so to say that you can pass parameters to Javascript using GET and POST methods, of course, but this will not be entirely true. Because parameters are transferred to the server, new content is generated there, and there you can do anything. Although directly taking GET variables from window.location.href, at least somehow the server language re-generates JavaScript every time. and this is just an imitation of JavaScript requests.
However, there is one character in the URL standard that will help us.
This is a pound symbol (#), although some say that it is a symbol of the English currency, but now it does not matter.
The trick is that if there is
some.so/index.php#id:2 in the cache,
we will request
some.so/index.php#idhaps
then the second page will be taken from the cache (which it got after the first request).
So, let's get down to business: after the pound sign in the URL, the following characters are allowed
: _ -.
and any latin characters.
Let the pair (key: value) be separated by a dot; the key itself is separated from the value by a colon, and escaping will be done using underscores.
Thus, if we want to pass 2 parameters, it will look something like this:
some.so/index.php#id:2.par2:dgsdgd
if we want to pass period , colon or non-latin characters, then we do it like this:
some .so / index.php # id: _56_34.par2: _21_20_54
Such JavaScript requests (jR = JavaScript Request) can be distinguished from the usual some.so/index.php#chapter7 links by the presence of a colon (:) after #, because I have never seen anyone put a colon there.
Writing js functions that will be processed by jR is not difficult - we take window.location.href, crop it with regexp, split the string into an array, split the array elements into a key and a value. That's all.
It really works, and really saves traffic, gives fun effects with AJAX, in general, experiment.
Of course, TBL would not be very happy with this use, but still, I think that client-side JavaScript has earned the fact that now it will be able to receive parameters directly for itself. Hurrah!