Which is/are correct?
-
xmlhttp.get("OPEN","samplePageUrl",true);
-
xmlhttp.open("GET","samplePageUrl",true);
-
xmlhttp.post("OPEN","samplePageUrl",true);
-
xmlhttp.open("POST","samplePageUrl",true);
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.
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.