• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 308
  • Last Modified:

ajax question

Can I use as the url for a ajax connection and how about sportsnetwork.com/NHL.XML I'm in the Domain of sportsnetwork can I use this for data retrieve or am I going to run into cross domain policy issue.
But I maybe wrong but if I use a IP Address and retrieve a xml file why would I get cross domain isn't that a way to beat cross domain I wrote code but I'm not getting two team name as a test. here is code.

<!doctype html>
<meta charset="utf-8">
<title>Untitled Document</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">

var xmlPath = ''

        type: "GET",
        url:  xmlPath,
        dataType: "xml",
        success: function(data) {
            var d = $(data);
			var Play = d.find('message');
                var listing=$(listing);
				var awayteam = team.attr("awayteam");
                var hometeam = team.attr('hometeam'); 


<table width="350" border="0">
    <td><div align="center" id="txthometeam">Hometeam</div></td>
    <td><div align="center" id="txtawayteam">Awayteam</div></td>

Open in new window

  • 3
  • 3
1 Solution
As long the domain you are calling by ajax is exactly the same (protocol and address) then there is no problem, if it isn't then you can use Jsonp or a proxy.
IP addresses are not the same as the domain
powerztomAuthor Commented:
So IP Address should work right? If so

is this not right cause if I can connect the world will open up for me. There is so much I can retrieve it will be unbelievable.

Tell me what is wrong with this

var xmlPath = ''
should it be

var xmlPath = '' but neither one worked for me. Please let me know. cause this is what I get

Error: 0 - [Exception... "Access to restricted URI denied"  code: "1012" nsresult: "0x805303f4 (NS_ERROR_DOM_BAD_URI)"
Are you loading your webpage using that IP address as well?
Is that IP address mapped to one single domain as a default?

If in the address bar you have http://www.mydomain.com then you have to use http://www.mydomain.com for your ajax call.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

powerztomAuthor Commented:
No the IP Address is remote on a remote computer from the webpage

The IP Address is in  a single domain but when you say is it mapped what do you mean like is it a domain controller or is IP Address have a dns domain name  yes it's name on network is tsnsql22
Do you have control over that domain/IP?

You can either...
Add an header to that IP
Access-Control-Allow-Methods: GET, POST, OPTIONS
Access-Control-Allow-Credentials: true
Access-Control-Allow-Origin: http://www.yourdomain.com
Access-Control-Allow-Headers: Content-Type, *

Open in new window

HOw you do this depends on your programming language/server.

Use Jsonp

Or use a proxy - this means you call a page on your own server which in turns calls the above IP for its data and then passes that data back to your page.
powerztomAuthor Commented:
Gary provided valuable insight regarding my question. Thanks G
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now