I had a peculiar requirement where I had to grab the entire query string (GET parameters) from the current page and send it to the ajax call happening on the same page.
Here is how I did that
$.ajax({
url: "/your/ajax/url"+location.search,
dataType: "json",
async: false,
success: function (data) {
console.log(data)
}
});
With location.search
, you get the entire query string from the current page. I am then appending it to the ajax URL to send the parameters as a GET request.