Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

如何在 onRequest中进行网络请求? #46

Open
lgc0313 opened this issue Mar 27, 2020 · 1 comment
Open

如何在 onRequest中进行网络请求? #46

lgc0313 opened this issue Mar 27, 2020 · 1 comment

Comments

@lgc0313
Copy link

lgc0313 commented Mar 27, 2020

在onRequest想进行同步网络请求。
发现用jquery $.ajax无法发送请求

@wendux
Copy link
Owner

wendux commented Apr 7, 2020

因为ajax-hook已经全局代理了浏览器原生的XMLHttpRequest,所以如果想在钩子函数中单独发起网络请求,可以使用浏览器原生的XMLHttpRequest,proxy()和hook()方法的返回值就是浏览器原生的XMLHttpRequest对象, 比如:

var _XHR=proxy(...)
...
var xhr=new _XHR
xhr.open(url)
xhr.send(...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants