吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3174|回复: 21
收起左侧

[求助] jquery前端跨域请求的问题

[复制链接]
cqwcns 发表于 2021-9-30 13:16
代码如下,我希望获得服务器返回数据,但控制台提示为:跨源读取阻止(CORB)功能阻止了 MIME 类型为 application/json 的跨源响应。
尝试某度的多种方法,未能解决。
麻烦各位大佬指教。


[HTML] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<!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">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <title>Document</title>
</head>
 
<body>
    <button>查询</button>
 
    <script>
        $('button').click(function () {
 
            $.ajax({
                type: "GET",
                url: "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=wxcc1fe14e3f&secret=9d8767fe1ecea0",
                dataType: "jsonp",
                success: function (data) {
                    console.log(JSON.stringify())
                }
            });
        });
 
    </script>
</body>
 
</html>

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

hualonghongyan 发表于 2021-9-30 13:24
跨域,需要后端开放
新手张浩 发表于 2021-9-30 13:27
 楼主| cqwcns 发表于 2021-9-30 13:35
但我用python是可以的,应该不是后端问题吧。

[Python] 纯文本查看 复制代码
01
02
03
04
05
06
07
08
09
10
11
import requests
import json
import time
 
import datetime
import pandas as pd
 
# 获得token
this_token = requests.get(
    url='https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=w***********xf14f&secret=9daf*e1ecea0'
).json()
江南小公子 发表于 2021-9-30 13:37
本帖最后由 江南小公子 于 2021-9-30 14:06 编辑

只能后端解决,或者你写个代{过}{滤}理接口,伪装Referer头。你可以看看这个链接
[解决跨域问题](https://www.cnblogs.com/wasbg/p/10844274.html)
djnym 发表于 2021-9-30 13:37
这个需要后端支持吧
利进颖 发表于 2021-9-30 13:42
jq不知道能不能代{过}{滤}理,你python访问跟ajax不是一个东西,js是在基于浏览器的情况下进行访问的,那个请求是在浏览器发出的,w3有他的规则,你不能那样子玩
抖阴视频 发表于 2021-9-30 13:45
试试crossDomain: true
时光书窝 发表于 2021-9-30 13:45
cqwcns 发表于 2021-9-30 13:35
但我用python是可以的,应该不是后端问题吧。

[mw_shl_code=python,true]import requests

Python和浏览器不一样的,浏览器有浏览器的规则,安全策略
rushuang 发表于 2021-9-30 13:52
一般后端控制类上加一个注解@CrossOrigin放行
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2025-5-25 17:53

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表