I have following JSON STRINg as a result of a jquery function
作为jquery函数的结果,我遵循JSON STRINg
{"error":"","status":"1","data":[{"id":"6","ringSetName":"DFWR0319 - 18K White Gold 30RD.45ctw Pave Halo Engagement Ring(does not include center diamond)","ringSetCategories":"Halo","ringThumbNailImagePath":"http:\/\/thevowapp.com\/iphoneapp\/ringthumbs\/DI004_R_Thumb_White_WBG_00001.jpg","ringOnHandImagePath":"http:\/\/thevowapp.com\/iphoneapp\/handrings\/DI004_R_handring_White_WBG_00001.png","ringSetClientName":"Cherie Dori","ringDescription":"This angel's halo has 30 precision set round brilliant diamonds that wrap around your center diamond. *center diamond sold separately, mounting can be modified for any size or shape center diamond","ringHDir":"http:\/\/thevowapp.com\/iphoneapp\/ringmodels\/NL\/DI004_IPad\/IPad_DI004_H_White_000_Diamond_E_800x600.zip","ringRDir":"http:\/\/thevowapp.com\/iphoneapp\/ringmodels\/NL\/DI004_IPad\/IPad_DI004_R_White_000_Diamond_E_800x600.zip","ringPicDir":"http:\/\/thevowapp.com\/iphoneapp\/ringmodels\/NL\/DI004_IPad\/IPad_DI004_RPic_White_000_Diamond_E_800x600.zip{}http:\/\/thevowapp.com\/iphoneapp\/ringmodels\/NL\/DI004_IPad\/IPad_DI004_RPic_Yellow_000_Diamond_E_800x600.zip","forteenk":"860","eighteenk":"930","platinium":"1,211.00","ringSetKaratQuality":"18K","videos":"http:\/\/vimeo.com\/81502294, http:\/\/vimeo.com\/81502295\r\n","ringWebFolder":"DI004_FWR0319"}]}
Now data is always an array with 1 ELEMENT. Using this code how can i get value of ringWebFolder
现在数据总是一个带有1个ELEMENT的数组。使用此代码我如何获得ringWebFolder的值
.done(function( msg )
{
if( msg.status=="1")
{
var path = 'DiadoriAllrings/'+ msg.data.ringWebFolder; // IT SAYS UNDEFINED
path = path.concat("/No_Logo");
alert(path);
initSwf(path);
} else {
alert("Error : "+msg.error);
}
jQuery('#sliderloading').addClass('hide');
});
1 个解决方案
#1
6
msg.data is an array with 1 element (an object). You can select the first element in the array by index, then the property of the object.
msg.data是一个包含1个元素(对象)的数组。您可以按索引选择数组中的第一个元素,然后选择对象的属性。
You can use:
您可以使用:
msg.data[0].ringWebFolder
#1
6
msg.data is an array with 1 element (an object). You can select the first element in the array by index, then the property of the object.
msg.data是一个包含1个元素(对象)的数组。您可以按索引选择数组中的第一个元素,然后选择对象的属性。
You can use:
您可以使用:
msg.data[0].ringWebFolder