0

I am trying to access an xml file suing jquery and ajax call. I found that that cross domain request are not allowed unless you do some config changes on the web server.

I am doing this:

$(document).ready(function () {

$("#div1").jstree({

    "xml_data": {

        "ajax": {
            type: "GET",
            dataType: 'xml', 
            url: "http://192.168.101.1/img/tree.xml"

I have modified iis web.config file as follows:

<?xml version="1.0" encoding="utf-8"?>
  <configuration>
    <system.webServer>
      <httpProtocol>
        <customHeaders>
          <add name="Access-Control-Allow-Origin" value="*" />
        </customHeaders>
      </httpProtocol>
    </system.webServer>
  </configuration>

Recycled IIs but I still cannot access that xml file. Any ideas how I can tackle this issue?

Community
  • 1
  • 1
user1471980
  • 10,127
  • 48
  • 136
  • 235
  • 1
    Are you seeing any errors? And, are you seeing the request being made by your client (e.g. you see the request being sent in Fiddler, FireBug, Chrome Tools, etc.)? – David Hoerster Aug 21 '12 at 17:02
  • I dont see any errors from the IIS log. I cannot tell a request is being made since there is no entry in the iis event viewer. – user1471980 Aug 21 '12 at 17:09
  • What browser are you testing in? I remember there being an issue with making CORS requests in IE, it required additional code. – Kevin B Aug 21 '12 at 17:48
  • Also, remove `crossDomain: true,` it isn't relevant to what you are doing. That option is meant for forcing jQuery to treat a local request as a crossDomian quest. You aren't making a local request. – Kevin B Aug 21 '12 at 17:49

2 Answers2

0

Try to send ajax request to your app, and get this xml from app to not bother with cross-domains calls.

Michael
  • 1,067
  • 8
  • 13
0

Maybe you need to set your crossdomain.xml in the server.

Example to put on root of the project:

<?xml version="1.0"?>
<!DOCTYPE cross-domain-policy SYSTEM "http://www.adobe.com/xml/dtds/cross-domain-policy.dtd">
<cross-domain-policy>
    <allow-access-from domain="*" />
    <site-control permitted-cross-domain-policies="master-only"/>
    <allow-http-request-headers-from domain="*" headers="*" secure="true"/>
</cross-domain-policy>

Also worth reading where to place the file.

Community
  • 1
  • 1
pdjota
  • 3,163
  • 2
  • 23
  • 33