Ver Fonte

20210811

邪性 há 3 anos atrás
pai
commit
d48f9c38a6
1 ficheiros alterados com 69 adições e 0 exclusões
  1. 69 0
      jsonp.html

+ 69 - 0
jsonp.html

@@ -0,0 +1,69 @@
+<!DOCTYPE html>
+<html lang="en">
+
+<head>
+  <meta charset="UTF-8">
+  <meta http-equiv="X-UA-Compatible" content="IE=edge">
+  <meta name="viewport" content="width=device-width, initial-scale=1.0">
+  <title>Document</title>
+  <script src="./js/jquery.js"></script>
+</head>
+
+<body>
+  <script>
+    // $.ajax({
+    //   url: 'http://127.0.0.1:9000/jsonpb',
+    //   dataType: "jsonp",
+    //   jsonp: "successCallback",
+    //   jsonpCallback: 'successCallback',
+    //   success (res) {
+    //     console.log(res)
+    //   }
+    // });
+
+    // function successCallback (data) {
+    //   console.log("更改名称", data)
+    // }
+
+
+    $(function () {
+      // post
+      let url = 'https://ip.taobao.com/outGetIpInfo';
+      url = "http://127.0.0.1:9000/jsonp";
+      // cor阻止的
+      // $.ajax({
+      //   url,
+      //   type: "get",
+      //   success: function (res) {
+      //     console.log(res)
+      //   }
+      // });
+      // 跨域的
+      $.ajax({
+        url,
+        type: "get",
+        dataType: "jsonp", //指定服务器返回的数据类型
+        // jsonpCallback: "showData",
+        success: function (res) {
+          console.log("jsonp的callback: ", res)
+        }
+      });
+      // 跨域的
+      // $.ajax({
+      //   url: "http://127.0.0.1:9000/jsonpa",
+      //   type: "get",
+      //   dataType: "jsonp", //指定服务器返回的数据类型
+      //   // jsonpCallback: "showData",
+      //   success: function (res) {
+      //     console.log("jsonpa", res)
+      //   }
+      // });
+
+    })
+
+
+
+  </script>
+</body>
+
+</html>