Within my web service, I have a method that returns a JSON object:
{name:'xx'}
When making an Ajax request and parsing the response with 'eval', I encountered an issue.
onComplete:function(req){
var data=eval(req.responseText);
//perform actions based on data
}
However, I was unable to retrieve the 'data' as intended.
Upon returning the following string instead:
[{name:'xx'}]
It worked, allowing me to obtain the 'data' as an array.
After researching through Google, I learned this is due to the presence of '{' in the return string.
This led me to question if there is a different approach to return a JSON object?