We all know with CRM 2016 we should use Web API instead of oData in JavaScript. So before actually implementing that let us understand XMLHTTPRequest which would be a major part of this code.
Lets take a code example and then analyze each and every component
The following script demonstrates how to create and use the XMLHttpRequest object. For best client-side performance, the XMLHTTP request is asynchronous and uses an onreadystatechange event handler to process the data returned by the call. The script uses the getXMLHttpRequest()function defined above to create the request object.
The full list of readyState
values is:
State Description
0 The request is not initialized
1 The request has been set up
2 The request has been sent
3 The request is in process
4 The request is complete
function handler() { if (oReq.readyState == X /* complete */) { if (oReq.status == 200) {/*Click here to check all statuses possible*/ console.log(oReq.responseText);/*Responsetext property*/ } } } var oReq = getXMLHttpRequest(); if (oReq != null) { oReq.open("GET", "http://localhost/test.xml", true); oReq.onreadystatechange = handler; oReq.send(); } else { window.console.log("AJAX (XMLHTTP) not supported."); } Sample Workout
Further process to be followed in my next post..
Cheers,
PMDY