4

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

        });
2
  • 2
    msg.data[0].ringWebFolder Commented May 15, 2014 at 14:04
  • Is it really so hard to read the documentation? developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/… How can one with 2368 reps ask such a question while in almost every invented language the notation for accessing array elements is the same??? Commented May 15, 2014 at 14:07

1 Answer 1

8

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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.