Cross-domain Ajax (CORS)

Cross-domain Ajax (CORS)

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. 
  1. makeCorsRequest('http://findconcertsservice.cloudapp.net/FindConcertsService.svc/help/operations/findAll',
  2.       'GET');
This is my function:

  1. // Create the XHR object.
  2. function createCORSRequest(method, url) {
  3. var xhr = new XMLHttpRequest();
  4. if ("withCredentials" in xhr) {
  5. // XHR for Chrome/Firefox/Opera/Safari.
  6. xhr.open(method, url, true);
  7. } else if (typeof XDomainRequest != "undefined") {
  8. // XDomainRequest for IE.
  9. xhr = new XDomainRequest();
  10. xhr.open(method, url);
  11. } else {
  12. // CORS not supported.
  13. xhr = null;
  14. }
  15. return xhr;
  16. }

  17. // Helper method to parse the title tag from the response.
  18. function getTitle(text) {
  19. return text.match('<title>(.*)?</title>')[1];
  20. }

  21. // Make the actual CORS request.
  22. function makeCorsRequest(url, type) {
  23. var xhr = createCORSRequest(type, url);
  24. if (!xhr) {
  25. alert('CORS not supported');
  26. return;
  27. }

  28. // Response handlers.
  29. xhr.onload = function() {
  30. var text = xhr.responseText;
  31. var title = getTitle(text);
  32. alert('Response from CORS request to ' + url + ': ' + title);
  33. };

  34. xhr.onerror = function() {
  35. alert('Woops, there was an error making the request.');
  36. };

  37. xhr.send();
  38. }

The only anwser I have is "Woops, there was an error making the request".

Could you guys please help me out ?

Thanks so much !