UNPKG

odataserver

Version:

OData server with support for BLOBs

53 lines (39 loc) 1.36 kB
<!doctype html> <html> <body> <input type='button' id='cors' value='cors request in iframe window' /> <br/> <script> 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', 'http://appdev.gizur.com:9000/0b213a639078/b_rootapp', 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> </body> </html>