Ajax/jQuery problem

Posted by Lucho on Stack Overflow See other posts from Stack Overflow or by Lucho
Published on 2010-04-22T19:05:29Z Indexed on 2010/04/22 19:23 UTC
Read the original article Hit count: 309

Filed under:
|

Hi,

I'm rookie when it comes to Ajax and jQuery and needs some help...

The following url produces an xml-file that I want to use on my page: http://ws.spotify.com/search/1/track?q=foo

When I use firebug it seems like nothing comes back. What have I done wrong?

This is what my code looks like:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
     <head>    
         <title></title> 
         <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.1/jquery.min.js"></script> 
         <script type="text/javascript"> 
         $(document).ready(function(){
            $.ajax({
                url: 'http://ws.spotify.com/search/1/track?q=foo',
                type: 'GET',
                contentType: "application/xml; charset=utf-8",
                error: function(){
                    alert('Error loading XML document');
                },
                success: function(xml){
                    alert("success");
                    $(xml).appendTo("#result");                   
                }
            });
        });
         </script> 
     </head> 
     <body> 
        <div id="result">
        </div>       
     </body> 
 </html>

© Stack Overflow or respective owner

Related posts about jQuery

Related posts about AJAX