- ajax, script URL-, - RESTful, JavaScript ( JSON). , eval.
:
script , . , script , onload (, , onload, IE script), , . ( ):
function test ()
{
this.init = function ()
{
var script = document.createElement("script");
script.type = "text/javascript";
script.language = "javascript";
script.src = "test.js";
var me = this;
window.callMe = function () { me.scriptReady(me); };
var head = document.getElementsByTagName("head")[0];
head.appendChild(script);
};
this.scriptReady = function (object)
{
serverResponse.call(object);
};
this.name = "From inside the object";
this.init();
}
var t=new test();
:
function serverResponse()
{
alert(this.name);
}
window.callMe();
serverResponse() "this". , :
function serverResponse()
{
this.serverJSONString = { "testVar1": "1", "testVar2": 2 };
function Test()
{
alert("From the server");
}
Test();
}
window.callMe();
, , . , JSON, , .
, , , , , .
P.S. IE, . IE, script .
P.P.S. , , , . , , : -)