Hey guys,
I've seen many tutorials and several posts here on jQuery but no one could help me.
but somehow is not possible ....
I'm using some code I found on internet.
- makeCorsRequest('http://findconcertsservice.cloudapp.net/FindConcertsService.svc/help/operations/findAll',
- 'GET');
This is my function:
- // Create the XHR object.
- 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;
- }
- // Helper method to parse the title tag from the response.
- function getTitle(text) {
- return text.match('<title>(.*)?</title>')[1];
- }
- // Make the actual CORS request.
- function makeCorsRequest(url, type) {
- var xhr = createCORSRequest(type, url);
- if (!xhr) {
- alert('CORS not supported');
- return;
- }
- // Response handlers.
- xhr.onload = function() {
- var text = xhr.responseText;
- var title = getTitle(text);
- alert('Response from CORS request to ' + url + ': ' + title);
- };
- xhr.onerror = function() {
- alert('Woops, there was an error making the request.');
- };
- xhr.send();
- }
The only anwser I have is "Woops, there was an error making the request".
Could you guys please help me out ?
Thanks so much !