Hi I'm Will. I've been messing with markup and script for years. Pretty much on my own though. I'm not part of a team of developers so I'm here to formulate what is missing when working alone - I want to be able to grow my knowledge even further in return for offering others what I already know well - to continue learning together. I joined to get answers to coding problems more quickly and in return offer my own experience in making websites responsive and how I achieve my aim of creating sites that are fully W3C valid, streamlined and device responsive. I look forward to sharing code ideas.
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (8)
My first question is as follows:
Passing a variable works in this scenario - ./filename.php?variable=1
It however fails with a js file - ./filename.js?variable=1
Someone please point out the obvious, I'm stuck :/
Can you provide a scenario where you need to statically call a script file with a query?
This is done under the server and can be implemented with url rewrite or middleware or other.
The existence of a query string also eliminates the need to mess with the cache.
Usually, the JavaScript file needs to be created dynamically for languages, user personalization items, etc. (of course, it is not recommended to use external scripts).
Example
Url:
example.com/script/language.js/?value=en
Thank you Elanatframework. With regard to the 'example.com/script/language.js/?value=en' does a slash always have to be added between .js and the'?'. In other words this example would not work - example.com/script/language.js?value=en (no forward slash)? Please bear in mind I know very little about coding at this stage... lots still to learn :)
Just tried the following:
domain.com/file.php?variable=var --- this works (difference is php)
domain.com/file.js?variable=var --- this fails (difference is js)
domain.com/file.js/?variable=var --- this fails (difference is js/)
Thanks
Will
Dear Willem de Beer
I apologize for the mistake in the extra slash and confusion!
This link
example.com/script/language.js?value=en
is standard and correct.This example is related to server codes.
In fact, a programming language (such as PHP or Python, etc.) on the server creates this
language.js
file virtually.The
language.js
example is a special example and you usually don't need to do this.HTML, JavaScript, and CSS run in your browser. The addition of
?value=en
is to send the value of en from your browser to the server.You don't need to send data to JavaScript as a query. JavaScript can read the query string from anywhere it is executed and there is no need to do this.
Hello Will! Welcome to our wonderful community! ๐ I am the unofficial welcome committee but you can just call me Anita ๐
Hi Anita. Thank you.
Learning together is always better.