JSONP cross-domain GET200 but still report an error and go directly to the error handler

the code is as follows:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Ajaxjson</title>
    <script type="text/javascript" src="jquery-3.3.1.js"></script>
</head>
<body>
    <button id="btn">ajax</button>

    <script type="text/javascript">

        $("-sharpbtn").click(function() {
            $.ajax({
               type : "get",
               async: false,
               url : "http://yunxtec.com/test/adlist.json",
               dataType: "jsonp",
               jsonp:"callback",
               success : function(data) {
                       alert(data[0][1]);
               },
               error : function(r) {
                       alert("fail");
               }
           });
        })
    </script>
</body>
</html>

Screenshot of error message is as follows:

GET200:

json:

what is the problem? How do I write if I want to get the index of adlist? Paste the code ~ ~

if you can

the problem has perplexed me as a rookie for a long time. Ask for help!

Mar.16,2021

jsonp returned data is not in the correct format, it should be callback (json) instead of json


  1. from the point of view of the error, it is a syntax error, which does not seem to be the problem of the request, but the problem with the json. Find a website to test the format of this json.
  2. get index? Array method map take all or find take 1

Don't talk too much nonsense, just code.

$.ajax({
          type: "POST",
          url: '/baidu/map/initLink',
          dataType : "json",
          contentType: "application/json;charset=utf-8",
          success: function(data){
              
                  //console.log(data);
                for(var i=0;i<data.length;iPP){
                    var polyline = new BMap.Polyline([
                    new BMap.Point(data[i].callLongitude,data[i].callLatitude),//
                    new BMap.Point(data[i].calledLongitude,data[i].calledLatitude)], //
                    {strokeColor:"green",// 
                    strokeWeight:3, //
                    strokeOpacity:0.5});//
                     map.addOverlay(polyline);    
                }
          }
      });
      

your data is json, not jsonp,. If the server is not under your control, you will have to figure out a way to get a reverse proxy.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1ea219c-1bb1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1ea219c-1bb1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?