UNPKG

odataserver

Version:

OData server with support for BLOBs

59 lines (42 loc) 1.52 kB
<!doctype html> <html> <body> <h1>Open the console to view the result.</h1> <input type='button' id='cors' value='cors request in main window' /> <br/> <script> var TEST_URL = 'https://odata.gizur.local/0b213a639078/b_rootapp'; var corsRequest = function() { console.log('corsRequest'); // Helper method to parse the title tag from the response. function getTitle(text) { return text.match('<title>(.*)?</title>')[1]; } var xhr = new XMLHttpRequest(); // Response handlers. xhr.onload = function() { var text = xhr.responseText; var title = getTitle(text); alert('Response from CORS request to ' + ': ' + title); }; xhr.onerror = function() { alert('Woops, there was an error making the request.'); }; // Test another CORS request - just to see that it works //xhr.open('GET', 'http://updates.html5rocks.com', true); //xhr.send(); // Test on the development server xhr.open('GET', TEST_URL, true); xhr.send(); // Test on localhost //xhr.open('GET', 'http://localhost:9000/0b213a639078/b_rootapp', true); //xhr.send(); }; document.addEventListener("DOMContentLoaded", function(event) { console.log('DOMContentLoaded'); document.getElementById('cors').addEventListener('click', corsRequest, true) }); </script> <iframe src='frame.html' sandbox='allow-scripts allow-forms allow-same-origin' /> </body> </html>