简体   繁体   中英

java script to get xml from url

I am writing a js to get a xml from a url but i am not getting any response.Anything I am doing wrong?

  $(document).ready(function () {
            $.ajax({
            type: "GET",
            url: "http://www.w3schools.com/xml/simple.xml",
            dataType: "xml",
            success: function(response)
                {
                    alert(response);
                }
        });


    });

http://jsfiddle.net/4bh0qpb1/1/

您忘记用双引号将url参数结尾

First script syntax error (") that you have fixed, although you can't access following url http://www.w3schools.com/xml/simple.xml using ajax due to CORS (Cross-origin resource sharing) Policy.

Reason Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://www.w3schools.com/xml/simple.xml . This can be fixed by moving the resource to the same domain or enabling CORS.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM