Browse Source

解决跨域

heyang 3 years ago
parent
commit
6831e6e3ed
1 changed files with 5 additions and 3 deletions
  1. 5 3
      microserviceUserH5/vcloud/channel.html

+ 5 - 3
microserviceUserH5/vcloud/channel.html

@@ -56,7 +56,8 @@
 			url: baseUrl + `/api/ditch/goAppDownload?code=${data.code}&platform=${data.platform}`,
 			type: 'get',
 			contentType: "application/json",
-			dataType: 'json',
+			dataType:"jsonp",    //跨域json请求一定是jsonp
+    		jsonp: "callbackparam",    //跨域请求的参数名,默认是callback
 			cache: false,
 			success: function (res) {
 				if (res.status === 0) {
@@ -84,7 +85,8 @@
 			data: JSON.stringify(data),
 			type: 'post',
 			contentType: "application/json",
-			dataType: 'json',
+			dataType:"jsonp",    //跨域json请求一定是jsonp
+    		jsonp: "callbackparam",    //跨域请求的参数名,默认是callback
 			cache: false,
 			success: function (res) {
 				if (res.status === 0) {
@@ -105,7 +107,7 @@
 			success: function () { }
 		})
 	}
-	visit()
+	// visit()
 </script>
 </body>
 <style>