Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Data Eval broken or am I missing something?

Hi, I was working on a project, but it suddenly stops evaluating data array from php to json output. I loaded older backups, but not a chance. Here's my code and error output. Thank you very much.

Code Sample ->

var data = eval('('+this.responseText+')');
infoView.text = data.length;
totalEvent = data.length;

Ti.API.info(data);

for (var c=0;c<data.length;c++){
eventName = data[c].eventName;
eventVenue = data[c].venueName;
eventTime = data[c].eventTime;
eventId = data[c].eventId;
mountainView[c] = Titanium.Map.createAnnotation({
});

Error ->

line = 111;
message = "Result of expression 'data' [null] is not an object.";
name = TypeError;
sourceId = 149940432;

I also tried json.parse() but nope :(

— asked September 28th 2010 by Can Soysal
  • eval()
  • iphone
  • json
  • xhr
2 Comments
  • what is the output of Ti.API.info(data)…..?

    — commented September 29th 2010 by Varun Atluri
  • & Ti.API.info(totalEvent); ….?

    — commented September 29th 2010 by Varun Atluri

2 Answers

  • Accepted Answer

    You're sure you used the JSON.parse() method instead of eval? Other than that, use jslint.com to validate the JSON you're sending back.

    — answered September 29th 2010 by Ryan Asleson
    permalink
    0 Comments
  • Ryan, jslint says it's a valid data. Surprisingly, it started to work again. May be server side issue. Thank you again.

    — answered September 29th 2010 by Can Soysal
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.