Multiple choice technology web 2.0

Which is/are correct?

  1. xmlhttp.get("OPEN","samplePageUrl",true);

  2. xmlhttp.open("GET","samplePageUrl",true);

  3. xmlhttp.post("OPEN","samplePageUrl",true);

  4. xmlhttp.open("POST","samplePageUrl",true);

Reveal answer Fill a bubble to check yourself
B,D Correct answer
Explanation

The correct XMLHttpRequest methods are open() with method as first parameter (case-sensitive: "GET" or "POST"), not get() or post(). Options B and D correctly use xmlhttp.open() with proper method names. Options A and C incorrectly use lowercase get()/post() methods and uppercase "OPEN"/"POST" as parameters.

AI explanation

The XMLHttpRequest API's method for initiating a request is open(method, url, async), where method is the string "GET" or "POST" passed as the first argument — there is no separate .get() or .post() method on the object. So both xmlhttp.open("GET", url, true) and xmlhttp.open("POST", url, true) are valid calls (POST additionally needs a subsequent send(body) and typically a Content-Type header, but the open() call itself is correctly formed). The distractors invert the API by treating GET/POST as method names (.get("OPEN",...), .post("OPEN",...)), which isn't how the standard AJAX API works.