Hi,
I want to stop anchor tag request on ajax response.
Here is my code:
<a class="anchorTag" href="@Url.Action("ActionName", "ControllerName")" >Click Here...</a>
<script>
$(function () {
$('.anchorTag').click(function (e) {
var data = {
postID: 001
};
$.ajax({
type: "POST",
url: "../../ControllerName/ActionName",
data: JSON.stringify(data),
dataType: "json",
contentType: 'application/json; charset=utf-8',
success: function (response) {
if (response.success == true) {
}
else {
}
}
});
});
});
</script>
Please give me some solution to achieve this task.
Hemant Patel
04-Apr-2018Hi Franco,
I analyzed your code. You can achieve your task by using object.preventDefault().
But used this method carefully.
Your modified code is as follows:
I hope it's informative!!!