开发者

Setting xmlhttpRequest.setRequestHeader for an ajax call?

When I have an ajax call why should i set xmlhttpRequest.setRequestHeader ? is it not obvious from the ajax object t开发者_如何学编程hat we are sending an ajax request.


You have to understand first that AJAX request are HTTP request. When you add

xmlhttp.setRequestHeader('Content-Type','XXXXXXXXX');

it adds an header that define what kind of data will be contained in the body of the request. application/x-www-form-urlencoded means that the data will be form data. The data format could be something else. It's just that form data is the most common thing you will send to a server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜