Question

I have following JSON STRINg as a result of a jquery function

{"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

.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');

        });
Était-ce utile?

La solution

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.

You can use:

msg.data[0].ringWebFolder
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top