You develop an HTML5 application. The application uses an image that is returned from an HTTP
POST request.
You develop the following code: (Line numbers are included for reference only.)
You need to display the loaded image in the application.
Which code segment should you insert at line 04?

A.
Option A
B.
Option B
C.
Option C
D.
Option D
That fact that this is a POST request doesn’t make sense to me. None of the answers work as is. B works if the request method is changed to GET.
0
0
POST can be used to retrieve data as well as send data
0
0
function loadDoc() {
var xhttp = new XMLHttpRequest();
xhttp.open(“GET”, “/p1.png”, true);
var img = document.createElement(‘img’);
xhttp.responseType = ‘blob’;
xhttp.onload = function (e) {
if (xhttp.readyState == 4 && xhttp.status == 200) {
img.src = window.URL.createObjectURL(this.response);
document.body.appendChild(img);
}
};
xhttp.send();
}
0
0
Answer is B.
Below is JSFiddle.
It is assumed in the question that image is retrieved as POST request.
https://jsfiddle.net/maverickcalibre/11retvav/12/
0
0