How to keep current url including parameters in JavaScript
I am using the modal to edit data by using the code below, and when I click the 'Change' button, I want to keep the current url. Even when I set a parameter, I don't want me to lose the parameter.
This url has no parameters set. So, if I edit data in modal and click the 'change' button, I lose all the parameters I set and return to the initialized screen.
I am using Django and python, and I am getting parameter values through request.POST.get method in views.py .
function (data, status, xhr) {
let code = data.code
if (code === 'error') {
for (let i in fields) {
let key = fields[i];
let labelElement = editForm.find('label[for=' + key + ']');
let container = labelElement.parent();
if (key in data.error) {
container.addClass('card-inverse-danger');
const msg = data.error[key][0];
let text = $('<div class="text-danger small" style="line-height: 1rem;">' + msg + '</div>')
labelElement.find('.text-danger').remove();
labelElement.append(text);
} else {
container.removeClass('card-inverse-danger');
labelElement.find('.text-danger').remove();
}
}
} else if (code === 'success') {
window.location.href = '/study/help/'; --> I think I need to update this line.
}
})