Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
75
rated 0 times [  79] [ 4]  / answers: 1 / hits: 25462  / 10 Years ago, wed, april 2, 2014, 12:00:00

I have a function that sends an HTTP POST request and i want to log it for debugging purposes. 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?



Thanks.


More From » jquery

 Answers
10

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.



Even after that, if you want to log the XHtmlRequest, you can always do (if your browser supports console.log):



var xhr = $.ajax(...);
console.log(xhr);


Hope I've helped.


[#71655] Tuesday, April 1, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jerome

Total Points: 592
Total Questions: 98
Total Answers: 101

Location: Tonga
Member since Tue, Nov 30, 2021
3 Years ago
;