How do I get the content of this xml page?

http://2011.cma.gov.cn/qxxw/y.

I use jquery

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
</head>
<body>
    <script src="http://127.0.0.1/jquery-3.3.1.js"></script>
    <script>
function Ajax( ) {
     var url = "http://2011.cma.gov.cn/qxxw/yw/index_228.xml";
      $.ajax(url, {
        type:"GET",
        dataType: "jsonp",
        crossDomain: true,
            success:function(data){  
                alert(data);
            },
            error: function (e) {
                alert("error");
            }

      });
};
    </script>
  
    <input type="button" value="show content" onclick="Ajax();" />    

</body>
</html>

Why did I report an error and how to correct it?

May.15,2021

The content of

xml cannot be obtained through jsonp . The principle of jsonp is to introduce data as js through script .

you can consider the way of proxy and let the server get it.


jsonp is supported by the server, not the


that you want to use.

dataType should be xml

the code is as follows:

function Ajax( ) {
     var url = 'http://2011.cma.gov.cn/qxxw/yw/index_228.xml';
      $.ajax(url, {
        type:"GET",
        dataType: 'xml',
        crossDomain: true,
            success:function(data){  
                alert(data);
            },
            error: function (e) {
                alert("error");
            }

      });
};
Menu