0

I've got an url here

http://94.23.34.69:7240/ 

wich contains XML information. I need this information between the tags

<Name>IG_Battlegrounds</Name>
<MapName>Brezaliad</MapName>
<NumberOfActivePlayers>35</NumberOfActivePlayers>
<MaxNumberOfPlayers>50</MaxNumberOfPlayers>

When getting the information i need to print it into html. I managed to get this trough PHP but that is taking to long and makes my website load slowly. I haven't worked with ajax yet. I hope someone can help me. I tried to use this

  $.ajax({
      type: "GET",
    url: "http://94.23.34.69:7240/ ",
    dataType: "xml",
    success: function(xml) {           
        alert("xml");
    }
});

But this is not working. It doesn't show anything. Do i need to include something special for using ajax? I also need al the information comming from this link and break up the info so i can use parts of it to print to my website

http://module.game-monitor.com/85.236.100.184:8876/website.php?s=test.css&f=18

Help would be appriciated.

Tom Aalbers
  • 4,574
  • 5
  • 29
  • 51

1 Answers1

0

You cannot send an Ajax request to another domain other than yours.

https://en.wikipedia.org/wiki/Same-origin_policy

You can circumvent it using CORS (if you can manage the server) or using a proxy.

Ways to circumvent the same-origin policy

Community
  • 1
  • 1
sergiorz
  • 1
  • 2
  • What is the best way then to retrieve that data? When i use PHP it slows down my site and it needs settings to be on (cUrl) for it to work – Tom Aalbers Mar 10 '14 at 21:35
  • It's not bad using AJAX if XML does not contain any sensitive information (client side so clients can see full content from the code XML retrieved) but users must enable Javascript on their browser for using that method. Also you can use JQuery to process (or convert XML to JSON using a 3rd party library) the response. Anyway you need to use one of techniques mentioned above in order to circumvent Same Origin Policy. If you can manage the server, I think enabling CORS is the fastest option. – sergiorz Mar 10 '14 at 21:47