Lux Smith
Posts: 0
Joined: Fri Jan 10, 2014 4:52 am

Unable to use "data" param in success event and "Run Javascript" action of service response of a db service

data.length or data[0]. returns undefined in the success event and "Run Javascript" action of service response of a db service.

It seems to be working fine before the upgrade of the latest release. Has anything changed. What does "this" refer to in "function ( data ) { / this - current element"?

Alena Prykhodko
Posts: 0
Joined: Tue Apr 09, 2013 7:36 am

Unable to use "data" param in success event and "Run Javascript" action of service response of a db service

Hello Lux,

Could you please provide more details? What code do you run? Show us screen shots.

Have you tried rolling back your app to the old builder version?

:: http://devcenter.appery.io/documentat...

Does the behavior persist?

Matt6607699
Posts: 0
Joined: Sat Jan 25, 2014 7:18 am

Unable to use "data" param in success event and "Run Javascript" action of service response of a db service

I am getting this same issue. I run a google places search that returns multiple results. on success JS I run:

var len = data.length;
alert(len);

This keeps alerting(also tried to console.log();) undefined.

I can however access the data. for example:
alert(JSON.stringify(data.results[0].photos[0].photo_reference));
This alerts the photo reference number correctly.

Is there another way to get data.length?
I used data.length for a loop in the same success event JS and that doesn't work either.

Yurii Orishchuk
Posts: 0
Joined: Fri Feb 14, 2014 8:20 am

Unable to use "data" param in success event and "Run Javascript" action of service response of a db service

Hi Matt,

"data" variable - is just a parsed response from your service. If service will returns Object - it will be JS object. If you service returns an Array - it will JS array.

"data.length" - have only "Array" type of the JS object.

So in your case, your service returns "Object" this type of object does not have ".length" property.

But in your JS object there is "result" field - that is seems to be an array. So if you want to get length of this array - you can use following JS code:

pre

console.log("length = " + data.results.length);

/pre

Regards.

Return to “Issues”