exam questions

Exam 70-480 All Questions

View all questions & answers for the 70-480 exam

Exam 70-480 topic 3 question 2 discussion

Actual exam question from Microsoft's 70-480
Question #: 2
Topic #: 3
[All 70-480 Questions]

DRAG DROP -
You develop an HTML application that calls a web service to retrieve JSON data. The web service contains one method named GetFullName that returns an
Object named data. The data object contains two properties named GivenName and Surname.
You need to load data from the web service to the webpage.
How should you complete the relevant code? (To answer, drag the appropriate code segment or code segments to the correct location or locations in the answer area. Use only code segments that apply.)
Select and Place:

Show Suggested Answer Hide Answer
Suggested Answer:
You can access object properties in two ways:
objectName.propertyName
or
objectName[propertyName]
Reference: JavaScript Objects

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
charlesmun
Highly Voted 5 years, 4 months ago
Hi, Kyrylx: I think that the answer is correct because the sentence is telling you that the JSON has an object named 'data' that has two properties (GivenName and SurName). In order to access to these properties in the success method, first you need to retrieve the response (with 'res'). Then, you need to access to the object ('data' >> so 'res.data'). Finally, you can access to the properties (so, 'res.data.GivenName', for example).
upvoted 5 times
...
JuanraDiaz
Most Recent 4 years, 6 months ago
but says "..Object named data. The data object contains two properties named GivenName and Surname"., so res.data.GivenName and res,data.Surname
upvoted 2 times
...
ziemcd
4 years, 8 months ago
I thinks it's only res, becuase its meant to be of type json
upvoted 1 times
Dreamchaser1980
4 years, 6 months ago
Yes it would make sense to directly access the properties of the data object as res.GivenName, res.SurName. If you use res.data.GivenName, res.data.SurName that means that the service returns the following Json string, which to me is unlikly {"data":{"GivenName":"Guardian knight","Surname":"Robin Hood"}}.
upvoted 1 times
...
...
rambo123_
4 years, 9 months ago
KyryIx is correct
upvoted 1 times
...
KyryIx
5 years, 4 months ago
I test with: Default.php <?php header( "Content-Type: application/json" ); print( '{"GivenName":"Everton", "Surname":"Pereira"}' ); ?> Page.html window.onload = function(){ $(document).ready( function (){ $('#submit').click( function(){ $.ajax({ type: "POST", url: "Default.php/GetFullName", data: "{}", contentType: "application/json", dataType: "json", success: function (res){ var fullname = res; $("#GivenName").text( fullname.GivenName ); $("#Surname").text( fullname.Surname ); } }); }); }); } and "jquery-3.4.1.js" But using res.data has error. It's correct answer?
upvoted 2 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...