Click here to Skip to main content
15,887,416 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
I am loading my script like this:

JavaScript
var myTestString = "/modules/admin";
$.ajax({
type: "GET",
url: "../../includes/test_tooltip.js",
data: "module="+myTestString,
dataType: "script"
});


Is it possible to have access to module variable in my test_tooltip.js like this?

I tried this as well in my main js file:

JavaScript
var myTestString = "/modules/admin";
$.ajax({
type: "GET",
url: "../../includes/test_tooltip.js",
data: { module: myTestString },
dataType: "script"
});


And in test_tooltip.js this:
JavaScript
console.log("I am loaded!" + data.module);


My scenario is like this. I sometimes need to load that javascript and when i do, i do it in different modules, and i need this javascript to know which module because he will have to do some requests based on the module.

In php i know you can acces data with $_REQUEST["module"], if it could be done in javascript similar would be great.
I am sorry for poor english.

Right now to make it work i use
JavaScript
window.variable
and
JavaScript
delete window.variable
Posted
Updated 19-Aug-11 2:20am
v3

1 solution

You can parse for query variables in javascript, but you'll need your own function:
http://www.idealog.us/2006/06/javascript_to_p.html[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900