I'm currently developing a function that streamlines the process of sending XMLHttpRequests.
This function is structured as follows:
XHR(url, method, data);
For example, if we call:
XHR('Hey.xml', 'get', { hi: 'hey' });
The result would be a request for "Hey.xml?hi=hey".
However, the challenge lies in the fact that different request methods handle query strings differently.
GET and HEAD require the query to be included in the URL itself.
On the other hand, POST needs the query to be sent with the following syntax:
request.send(query);
I'm aware that there are additional request methods available, and I am curious about how they handle query strings. Do they follow one of these patterns, or is there another approach entirely?
And before you suggest it, yes, I know there are already plenty of similar functions out there, including jQuery. But please refrain from recommending it.