I tried to submit the request with post method by clicking the element a
in HTML. But it always refreshes current page, even the action
is updated with correct value.
This is how I submit the request.
$(function() {
$('.detail a').click(function() {
$('#cityId').val($(this).data('cid'));
$('#cityName').val($(this).data('cn'));
$('#parentIds').val($(this).data('pids'));
$('#cityForm').submit();
});
});
I passed the values to the hidden elements for submitting with POST
method. Before the submit()
, I checked and the action attribute of form is the right URL I want. But, after it, it didn't redirect to the URL I set, it just refreshed the current page.
This is the a
in my code:
<a href data-cid="<c:out value='${cc.id}'/>" data-pids="<c:out value='${cc.type}'/>"
This is how the form
looks like:
<form id="cityForm" method="post" action="<%=basePath%><c:out value='${sp}'/>">
It did work in IE. I searched online and found some solutions saying that it's caused by Chrome takes it as the same request, so I need to add a timestamp after the URL, but didn't work for me.