简体   繁体   English

如何查看XMLHttpRequest对象

[英]How to view XMLHttpRequest object

I am new to JavaScript, so this is quite a basic question. 我是JavaScript新手,所以这是一个非常基本的问题。

I am creating a XMLHttpRequest object and am calling the setRequestHeader() method. 我正在创建XMLHttpRequest对象,并在调用setRequestHeader()方法。 For debugging, I want to be able to see the headers I have set on the XMLHttpRequest object before I call send() . 对于调试,我希望能够在调用send()之前查看在XMLHttpRequest对象上设置的标头。

There does not seem to be an API to getRequestHeader() , so is there another way to view my object as a string so I can debug?. 似乎没有用于getRequestHeader()的API,所以还有另一种方法可以将我的对象视为字符串以进行调试吗?

Update: Sorry, I need to make things clearer. 更新:对不起,我需要弄清楚点。 I am writing a PhoneGap application and do not have access to a Chrome console. 我正在编写PhoneGap应用程序,但是无法访问Chrome控制台。

you can use (the available methods in) the console object to debug your scripts. 您可以使用console对象(中的可用方法)来调试脚本。

var object = {test:1};
console.log(object);

Reference: console 参考: 控制台

在chrome上,使用控制台的“网络”标签,在firefox上,您可能需要使用firebug才能执行操作,您将看到有关xhr的所有信息

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM