
January 29th, 2013, 09:54 AM
|
 |
pollyanna
|
|
Join Date: Jul 2012
Location: Germany
|
|
Quote: | Originally Posted by hno2005 there is just a small problem , if the user puts 2 scripts like this in his website ,just one of them will work . |
Not sure what you mean by that. The global variables are available to any script, no matter how many there are.
Including an external script like in your example has little to do with passing variables to JavaScript. What it does is this: It sends a request to some server script (like a PHP file), which will use the parameters to generate(!) JavaScript code and send it back to the requesting page. So the data is not being sent to a JavaScript file. It's passed to a server script, which dynamically creates JavaScript code.
JSONP works like this.
So the question is: Do you want to generate JavaScript code depending on certain parameters? In that case, you need to set up a PHP script or something. Or do you have a given JavaScript file, which you want to send data to? In that case, do what I suggested above.
Last edited by Jacques1 : January 29th, 2013 at 09:57 AM.
|