PrepAway - Latest Free Exam Questions & Answers

You need to develop the application to meet the requirements

HOTSPOT
You are developing a web application that retrieves data from a web service. The data being retrieved is a
custom binary datatype named bint. The data can also be represented in XML.
Two existing methods named parseXml() and parseBint() are defined on the page.
The application must:
Retrieve and parse data from the web service using binary format if possible
Retrieve and parse the data from the web service using XML when binary format is not possible
You need to develop the application to meet the requirements.
What should you do? (To answer, select the appropriate options from the drop-down lists in the answer area.)
Hot Area:

PrepAway - Latest Free Exam Questions & Answers

Answer:

Explanation:
* accepts : ‘application/bint, text/xml’
accepts:’application/bin,text/xml’ to accept only XML and binary content in HTML responses.
* Use the following condition to check if the html response content is binary: If(request.getResponseHeader
(“Content-Type”)==”application/bint”
* var request = $.ajax({
uri:’/’,
accepts: ‘application/bint, text/xml’,
datafilter: function(data,type){
if(request.getResponseHeader(“Content-Type”)==”application/bint”)
return parseBint(data);
elsereturn parseXml();
},
success: function (data) {
start(data);
}
});

3 Comments on “You need to develop the application to meet the requirements

  1. Larsen says:

    The answer is correct. The type in datafilter is dataType, which doesn’t add the application part in application/. ContentType does keep the application part.




    5



    1

Leave a Reply