0
<script src="jquery-1.5.2.min.js" type="text/javascript">
        $(document).ready(function(){
            $.ajax({
                type: "GET",
                url: "http://rama.inescporto.pt/app/api/",
                data: "method=getGraph&artist=Coldplay&ri=3&p=3&d=0.5",
                dataType: "xml",
                success: xmlParser
            });
        });

        function xmlParser(xml) {

            $('#load').fadeOut();

            $(xml).find('element').each(function(){

                $(".main").append('<div class="artist"><p class="id">' + $(this).find('id').text() + '</p><p class="name">' + $(this).find("name").text() + '</p><p class="rank">Published ' + $(this).find("rank").text() + '</p></div>');
                $(".artist").fadeIn(1000);

            });
        }
    </script>
</head>
<body>
    <div class="main">
        <div align="center" class="loader"><img src="images/loading-spiral.gif" id="load" align="absmiddle"/></div>
    </div>

I think I have all correct, but the request does not happen, the success function does not kick in. Someone can see where did I get it wrong?

0

2 Answers 2

1

You cannot use AJAX to send a request to a different domain.

Sign up to request clarification or add additional context in comments.

1 Comment

well i'm in rama.inescporto.pt/app, so I just should use "api/" then, even so it does not work :/
0

Due to SOP browser rejects that request. You can use AJAX only on the same host (ip address and port), and the same protocol the original page is open from.

Edit: If your page is here: http://rama.inescporto.pt/ make sure that you are writing a correct relative path to the page you want to get through AJAX: /app/api.

Also, try to open http://rama.inescporto.pt/app/api/ in a browser. Do you get XML then?

1 Comment

The domain is different but that I got. My domain is ni.fe.up.pt/~ncruz/alpha/, so I'm using "/alpha/api/index.php" as URL and then the data. rama.inescporto.pt/app/api does return XML, "ni.fe.up.pt/~ncruz/alpha/api/…" does, but still using the url on the same domain, I do not get to success function :/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.