January 29th, 2013, 08:35 AM
How to post some data to a javascipt file
Hi every one
I want to post data , something like this :
is it possible ?
January 29th, 2013, 09:38 AM
all scripts run in the same context, so you could simply define a global variable in a script element to be used it in your external script:
Note, however, that you should generally avoid globals variables and hidden dependencies like that. If possible, wrap your code in an object or a function and pass the value as an argument. This way you can actually see where it comes from.
id = 5; // initialize variable for test.js
Also note that the language attribute is long obsolete. Use
January 29th, 2013, 10:18 AM
there is just a small problem , if the user puts 2 scripts like this in his website ,just one of them will work .
I'm using it for an gallery website . it shows top 10 images .everyone can get this code and use it in his blog or website and then it shows the latest images in his blog.
It has different parameters that user can set , like bg color.
This is an example :
how does it send these datas ? How can get them ?
January 29th, 2013, 10:54 AM
Not sure what you mean by that. The global variables are available to any script, no matter how many there are.
Originally Posted by hno2005
JSONP works like this.
Last edited by Jacques1; January 29th, 2013 at 10:57 AM.