When you create the file upload widget, you're passing it a configuration object. This object has a number of properties, among them url
.
The property values are evaluated when the object is created (in your case when you create the file upload widget in $(document).ready()
). The object has no knowledge of the globalVar
variable since the value that is assigned:
"ajax_handler.php?globalVar=" + globalVar
evaluates to a simple string (you're not passing it a reference to globalVar
or anything like that). The behavior you seem to be expecting could only happen if you'd assign a function to the url
property in which you reference globalVar
(I don't know whether the file upload plugin supports this).
So even if you change globalVar
at a later time, the file upload widget's url configuration option will stay the same. If you want to change it, you need to explicitly assign it again.