Barbara
Posts: 0
Joined: Mon Sep 17, 2012 8:42 am

Populating selects from rest service

I have previously successfully populated selects from rest services, but there has always been only 2 columns in the response array.

This time I have 3 columns in my response array, two of which I map to a select. The other one is dealt with in the success event.

This is not working though, I see the returned json is good, but only the first row gets populated in the select.

Isn't it possible to do this? I don't want to have to get the data twice as it is all related and comes from one SQL query.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Populating selects from rest service

Hello! Could you send us a screemshot of mapping?

Barbara
Posts: 0
Joined: Mon Sep 17, 2012 8:42 am

Populating selects from rest service

Hello Marina, where have you been I missed you Image

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Populating selects from rest service

I'm here :) Thank you, we'll take a look.

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Populating selects from rest service

Barbara, could you clarify please in more details what are you trying to do? We tried to figure out, but no luck.

Barbara
Posts: 0
Joined: Mon Sep 17, 2012 8:42 am

Populating selects from rest service

Ok I am returning a 3 column array from restservice

id, ingredient, aisle

I want to store id and ingredient in the select so an ingredient can be selected

I also need to know what aisle that ingredient is in so I run custom js on complete event of restservice to store the id and aisle for future reference.

So I mapped id and ingredient to the select, but only the first ingredient gets added to the select, which is actually just a placeholder with no id.

Does that help?

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Populating selects from rest service

You should map ings[] to selectmenuitem1

Barbara
Posts: 0
Joined: Mon Sep 17, 2012 8:42 am

Populating selects from rest service

Ooops, sorry missed that step. Woking now.

But my oncomplete js isn't

I now see jqXHR and textStatus in the event javascript. I assumed I could use jqxhr the same way as data, but it doesn't work

code
for (i in jqXHR.ings) {
ingid=jqXHR.ings.column1;
aisle=jqXHR.ings.column3;
hiddenhtml += "somehtml";
}
$('[name=hidden]').html(hiddenhtml);

Maryna Brodina
Posts: 0
Joined: Thu Apr 05, 2012 7:27 am

Populating selects from rest service

It seems it's jqXHR.ings, the easiest way to find out is to do console.log on that object.

Barbara
Posts: 0
Joined: Mon Sep 17, 2012 8:42 am

Populating selects from rest service

jqXHR.ings is undefined

Return to “Issues”