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.)
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.)
Isn’t the answer for the second option, “if(type == “application/bint”)”?
According to jQuery documentation, the dataFilter function accepts two arguments: The raw data returned from the server (data) and the ‘dataType’ (type) parameter. The dataType parameter is a string in the format xml, json, script, text, html, etc. The Content-Type response header will be in the appropriate format for this example, e.g. ‘text/xml’, ‘application/json’, ‘application/bint’, etc.
http://api.jquery.com/jQuery.ajax
Type: Function( String data, String type ) => Anything
A function to be used to handle the raw response data of XMLHttpRequest. This is a pre-filtering function to sanitize the response. You should return the sanitized data. The function accepts two arguments: The raw data returned from the server and the ‘dataType’ parameter.
What is the right answer here because ive seen multiple answers and i dont understand anymore.
When should i use DataType & if (type == “application/bint”) and when should i choose accepts & if (request.ResponseHeader…)
No I dont agree with that.
According to http://api.jquery.com/jquery.ajax/:
accepts (default: depends on DataType)
Type: PlainObject
A set of key/value pairs that map a given dataType to its MIME type, which gets sent in the Accept request header. This header tells the server what kind of response it will accept in return. For example, the following defines a custom type mycustomtype to be sent with the request:
dataType (default: Intelligent Guess (xml, json, script, or html))
Type: String
The type of data that you’re expecting back from the server. If none is specified, jQuery will try to infer it based on the MIME type of the response (an XML MIME type will yield XML, in 1.4 JSON will yield a JavaScript object, in 1.4 script will execute the script, and anything else will be returned as a string). The available types (and the result passed as the first argument to your success callback) are:
So technically it should be Option 6 and Option 2.