[英]jQuery.ajax() log the HTTP request
I have a function that sends an HTTP POST request and i want to log it for debugging purposes. 我有一个发送HTTP POST请求的函数,我想记录它以进行调试。 Here is the function:
这是功能:
function serverRequest(URL, DATA, callback) {
$.ajax({
url: URL,
type: "POST",
dataType: "text",
contentType: "text/xml",
processData: false,
data: DATA,
success: function (response) {
console.log(response);
callback(response);
},
error: function (response) {
console.log(response);
callback(null);
}
});
}
How can i log the whole HTTP POST request (HTTP Header + data), as soon as it is send? 如何发送,我如何记录整个HTTP POST请求(HTTP标头+数据)?
Thanks. 谢谢。
Look for the tab " Network " ( not the Console tab) on your Developer Tools (Ctrl+Shift+J) if you are using Chorme, or anythig similar if you are using another browser. 如果您使用的是Chorme,请在开发人员工具(Ctrl + Shift + J)上查找“ 网络 ”( 不是 控制台选项卡)选项卡,如果您使用其他浏览器,则查找类似的选项卡。
Even after that, if you want to log the XHtmlRequest, you can always do (if your browser supports console.log): 即使在那之后,如果你想记录XHtmlRequest,你总是可以做(如果你的浏览器支持console.log):
var xhr = $.ajax(...);
console.log(xhr);
Hope I've helped. 希望我帮了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.