Im using jquery to get a list of objects from the server.
(我正在使用jquery从服务器获取对象列表。)
Every object has two fields id
and singleValue
(on the server both of them are Strings).(每个对象都有两个字段id
和singleValue
(在服务器上,它们都是String)。)
I want to iterate over the list and put values in the correct elements.(我想遍历列表并将值放入正确的元素中。)
for(var i=0;i<response.listOfObjects.length;i++){
$(response.listOfObjects[i].id).val(response.listOfObjects[i].singleValue);
}
Nothing happend by running this code.
(运行此代码没有任何反应。)
List has correct values (checked it by alert("id: " + response.listOfObjects[i].id + " singleValue: " + response.listOfObjects[i].singleValue);
)(列表具有正确的值(通过alert("id: " + response.listOfObjects[i].id + " singleValue: " + response.listOfObjects[i].singleValue);
))
I also tried to do
(我也试着做)
$('#' + response.listOfObjects[i].id).val(response.listOfObjects[i].singleValue);
but still doesn't work.
(但仍然不起作用。)
How is it possible to solve this problem?
(如何解决这个问题?)
@EDIT the html looks like:
(@EDIT html看起来像:)
<div class="field-group" style="display: block;" original-title="" title="">
<label for="customfield_13307">PCN</label>
<input class="textfield text long-field" id="customfield_13307" name="customfield_13307" maxlength="254" type="text" value="">
<div class="description">EPCN</div>
</div>
The id
from the object is the id of the input.
(的id
从对象是输入的ID。)
@EDIT I used JSON.stringify(response):
(@EDIT我使用了JSON.stringify(response):)
{
"name":"ATB",
"listOfObjects":[
{
"id":"customfield_13305",
"type":"single",
"singleValue":"21766"
},
{
"id":"customfield_13307",
"type":"Text",
"singleValue":" aaaa"
},
{
"id":"customfield_13308",
"type":"Text",
"singleValue":" bbbb"
}
]
}
ask by Rodnev Dlog translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…