[jQuery] passing query string parameters to script file

[jQuery] passing query string parameters to script file


I am quite new to jQuery but it is coming in very handy already.
Currently, I am using it for some basic Ajax which calls a PHP script
to populate a small part of a web page. So I have a main file
index.php, my jQuery functions in functions.js and my Ajax populated
content in mycontent.php.
I am using the following code which works fine:
$("#sidebar").load("mycontent.php");
However, what I really need to do is pass a parameter to my php file
i.e.:
$("#sidebar").load("mycontent.php?id=" + id);
My problem is getting the id parameter into my javascript in the first
place, so that I can pass it to my PHP script.
I can do this if I include my script inline in my main PHP web page
index.php, because I can just echo out the id parameter using PHP in
the middle of my javascript.
However, I would prefer to keep my javascript in a separate file. I
have tried calling it using <script src="functions.js?id=5"></script>,
but I can't seem to access this parameter from within functions.js. If
I access location.href, I get the URL of the parent file (index.php)
instead of the URL of the script itself.
I realise that this is more of a general javascript issue, but I have
googled both general javascript and jquery docs without success. I am
hoping that jQuery has a nice way of making query string parameters
available to my scripts.
Thanks in advance for your time.
Janine.