Copy the below two javascript functions to the browser console and hit enter.
function createCORSRequest(method, url) { var xhr = new XMLHttpRequest(); if ("withCredentials" in xhr) { // XHR for Chrome/Firefox/Opera/Safari. xhr.open(method, url, true); } else if (typeof XDomainRequest != "undefined") { // XDomainRequest for IE. xhr = new XDomainRequest(); xhr.open(method, url); } else { // CORS not supported. xhr = null; } return xhr; } function makeCorsRequest(url) { // This is a sample server that supports CORS. var xhr = createCORSRequest('GET', url); if (!xhr) { console.log('CORS not supported'); return; } // Response handlers. xhr.onload = function() { var text = xhr.responseText; console.log('Response from CORS request to ' + url); }; xhr.onerror = function() { console.log('Woops, there was an error making the request.'); }; xhr.send(); }
Now, you can make a CORS request by calling the makeCorsRequest(<url>) function.
makeCorsRequest("https://example.com/api/GetResults?id=1");