I’m trying to write a object for an admin page. It usage should be real simple. Like
var u = new User();
u.openUser(user_id);
alert(u.user_name); etc.
I create a xmlhttp response object in the openUser function and retrive the data works fine.
The problem i have is that the ajax response function seams to drop its knowing if it own object.
ex;
[CODE]function User()
{
//Public parameters
this.user_id = 0;
this.user_name = “”;
//Public methods
this.openUser = c_user_openuser;
//Open user Function
function c_user_openuser(user_id)
{
//Sends the open user requesst to the server.
var url = “engine/xml_user.php”;
var pars = {
action: ‘open’,
user_id: user_id
};
//Request user XML from server
p_this.ajax = new Ajax.Request(url,
{
method: ‘get’,
parameters: pars,
asynchronous: true,
onComplete: c_user_showResponse
});
// Process (User) HTTP response and update the object
function c_user_showResponse(xmlHttpRequest, responseHeader) {
$(‘dumpzone’).value = xmlHttpRequest.responseText;
//Check if response is a valid xml
if(xml_validate(xmlHttpRequest,$(‘d_return’)))
{
var xmlDoc = xmlHttpRequest.responseXML;
rNode = xmlDoc.getElementsByTagName(“user”)[0];
//Assining parameters from XML
this.user_name = getNodeValue(rNode.getElementsByTagName(“name”));
}
else
{
alert(“Not a valid xml”);
}
}
}
}
problem is that u.user_name returns nothing…
I’m using protorype at this expample, and some outside functions (they all work so thats not the problem). I get the same error when i do it from scratch.