Accessing the calling object into ajax response... (not the ajax call)
- by Nishchay Sharma
I have an object of type Application (defined by me). Whenever an object of this type is created, it automatically loads a php file say "start.php" using jquery ajax and assign the response to a div say "Respo". Now what i want is to access the Application object from that Respo div. Unfortunately, i have no clue how to do this...
in my ajax call:
function Application(options)
{
.......
var appObj=this;
$.ajax({
url:appObj.location, //Already defined
success:function(data)
{
$("#respo").html(data);
}
});
}
Now in my Respo division i want to access that Application object... I tried:
alert(this)
but it resulted in an object of DOMWindow...
i tried editing success function as:
function Application(options)
{
.......
var appObj=this;
$.ajax({
url:appObj.location, //Already defined
success:function(data)
{
$("#respo").html("<script type='text/javascript'>var Self="+appObj+"</script>");
$("#respo").html(data);
}
});
}
But i ended nowhere. :( Although if i assign "var Self='nishchay';" then alerting Self from start.php gives nishchay but i am not able to assign the calling object of Application type to the Self variable. It is the only way I cud think of. :\
Please help me... actually my object has some editing functions to control itself - its look and feel and some other options. I want the code loaded by object to control the object itself.
Please help me..
Thanks in advance.
Nishchay