Javascript function push problem
Posted
by Stefan
on Stack Overflow
See other posts from Stack Overflow
or by Stefan
Published on 2010-03-29T10:47:12Z
Indexed on
2010/03/29
10:53 UTC
Read the original article
Hit count: 390
Hello i've following JS function.
responseData:function(resp){
this.jsondata = eval('(' + resp + ')');
this.propList = [];
for (var i = 0;i<this.jsondata.length;i++) {
for (obj in this.jsondata[i]) {
alert(obj); //shows the property name of obj
this.propList.push({
obj : this.jsondata[i][obj] //insert only simple obj string
});
}
}
return this.propList;
}
I want to insert in my propList the property name and the value, but instead inserting the property name this function inserts simple 'obj' as a string. What i'm doing wrong?
greetings Stefan
© Stack Overflow or respective owner