DRAG DROP
You are developing a web application that retrievesdata 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 by using binary format if possible
Retrieve and parse the data from the web service by using XML when binary format is not possible
You need to develop the application to meet the requirements.
What should you do? (To answer, drag the appropriate code segment to the correct location. Each code segment may be used once, more than once, or not atall. You may need to drag the split bar between panes or scroll to view content.)
A.
Why everybody choose requestResponseHeader() ??. It should be if(type==’application/bint’)..
http://api.jquery.com/jQuery.ajax/
I think it’s because datatype/type should contain only “bint” (which is not an available answer), but the contenttype/accepts should contain “application/bint”.
respuesta cual seria .. :S
it’s not
uri: ‘/’
but should be url: ‘/’, uri is unknown parameter and will be ignored.
let me explain what is type argument with this code snippet:
$.ajax({
// ..
dataType: ‘penis’,
dataFilter: function(data, type) {
alert(type); // nsfw!
// ..
}
})
on the same note.. accepts also doesn’t work as documented.
http://stackoverflow.com/questions/1145588/cannot-properly-set-the-accept-http-header-with-jquery
“contrary to dataType which is a string, the accepts parameter is a map and should be used like this:
$.ajax({
url: …
dataType: ‘json’,
accepts: {
xml: ‘text/xml’,
text: ‘text/plain’
}
});
”
http://stackoverflow.com/questions/11065252/what-is-the-point-of-jquery-ajax-accepts-attrib-does-it-actually-do-anything
accepts: ‘application/bint, text/xml’,
if(request.getResponseHeader(“Content-Type”) == “application/bint”)