Pau*_*nel 7 javascript webrequest httpwebrequest google-chrome-extension
当我使用Chrome API收听所有HTTP请求时,如何从中获取实际数据?
我的意思是如果请求是在php页面(XMLHttpRequest)上进行的,我该如何获取此页面的内容?
.
我现在正在使用ajax请求查询数据.但这不是一个好的解决方案.
主要问题是请求使用POST方法.从ajax查询收到的数据与从HttpRequest收到的数据不同.
抱歉,您无法通过 webRequest 获取响应正文,我所做的是尝试使用 ajax 请求第二次请求该 url。这很丑陋,我必须使用后台脚本请求内容,但它确实有效。
var get=function(url,callback){
var xmlRequest=new XMLHttpRequest();
xmlRequest.open('GET',url,true);
xmlRequest.send();
xmlRequest.onreadystatechange=function(){
if(xmlRequest.readyState==4){
callback(xmlRequest.responseText);
}
};
};
Run Code Online (Sandbox Code Playgroud)
您可以从 xmlRequest.responseText 获取响应正文
| 归档时间: |
|
| 查看次数: |
3477 次 |
| 最近记录: |