I have a remote function testdwr, which returns a list of objects(test). How should i parse the list of objects in the handler method? Code shown below
public List testdwr(String message) { Test test = new Test(); test.setName("mahati"); 开发者_如何学Go List arrayList = new ArrayList(); arrayList.add(test); return arrayList; }
handler method:
function update() { findaccounts.testdwr("somestring : ",function(data){ alert(data); }
the alert box gives the output as "object Object"!!
The ArrayList returned from the server will looks like,
[Object { name="Mahati"}, Object { name="meena"}, Object { name="keerthi" }.....]
You can have a loop like this,
for(var i=0; i<arrayList.length; i++)
{
var testObj = arrayList[i];
//Here, you can do what you want! like...
alert(testObj.name);
alert(testObj.age);
}
Like Blake said, try to use FireBug, its an addon for firefox.
You should be able to do something like data[0].name
Using alert(data.length) show show 1.
Have you tried using Firebug on Firefox. It allows you to set a break point in the javascript code and examin the variables.
精彩评论