forum

Home / DeveloperSection / Forums / How to prevent anchor tag request on ajax response?

How to prevent anchor tag request on ajax response?

Anonymous User 1181 03-Apr-2018

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.


c# mvc 
Updated on 04-Apr-2018
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By