0

The following URI works in my browser (getting back the intended xml file):

http://ipaddress:port/server/gate?Command=GET%26info

But when I write the following to work with jQuery, it doesn't. The response is 200 OK but I get a blank XML file.

$(document).ready(function() {
          $.ajax({
            type: "GET",
            url: "http://ipaddress:port/server/gate?Command=GET%26info",
            dataType: "xml",
            success: parseXml
          });
    });

I tried replacing the %26 with & but that doesn't work either. Is there something I am fundamentally doing wrong?

Legend
  • 113,822
  • 119
  • 272
  • 400
  • 3
    Is the HTML page the code is contained running on the same server? You cannot access another URL from Ajax calls due to the same origin policy. If it is on the same server, use `url: "/server/gate?Command=GET%26info",` – Felix Kling Jul 27 '10 at 17:35
  • 2
    Is your code and the other page you are trying to get in same domain? Cross domain will work in browser but not through ajax – Teja Kantamneni Jul 27 '10 at 17:35
  • My bad! Yes. They are on a different server. Thanks for the clarification.... Almost forgot about it for a second. – Legend Jul 27 '10 at 17:39
  • Voting to close since it's already been answered. – Matt Ball Jul 27 '10 at 17:47
  • @Bears will eat you - I don't think that's how it works – Jiaaro Jul 27 '10 at 17:58

1 Answers1

0

If you have access to the server that serves the xml, you can now in FF3.5 and IE8 and more use CORS - cross origin resource sharing. It works like magic

Example here in my question which has not yet been answered

Community
  • 1
  • 1
mplungjan
  • 169,008
  • 28
  • 173
  • 236