---
title: "How to prevent page refresh on ajax request?"  
description: "How to prevent page refresh on ajax request?"  
author: "Anonymous User"  
published: 2018-03-13  
updated: 2018-03-13  
canonical: https://www.mindstick.com/forum/34430/how-to-prevent-page-refresh-on-ajax-request  
category: "c#"  
tags: ["ajax", "asp.net mvc", "mvc", "mvc4"]  
reading_time: 3 minutes  

---

# How to prevent page refresh on ajax request?

Hi,

I have submitted the form through [ajax request](https://www.mindstick.com/forum/157891/what-is-the-role-of-the-jsonresult-class-in-mvc-how-can-it-use-to-return-data-to-an-ajax-request). But on [submission](https://www.mindstick.com/forum/156176/what-is-a-directory-submission) of the form, the page was refresh.

Please give me some idea to prevent [page refresh](https://www.mindstick.com/forum/158700/how-can-implement-client-side-form-submission-and-prevent-page-refresh-using-jquery) on [form submit](https://www.mindstick.com/interview/1297/how-to-submit-form-without-submit-button).

Here is my [code](https://yourviews.mindstick.com/view/85458/alan-turing-the-mastermind-behind-cracking-the-enigma-code-during-world-war-ii),

```
<html>
<head>
<link rel="stylesheet" href="~/Content/bootstrap.min.css">
<link rel="stylesheet" href="~/Content/font-awesome.min.css">
<script src="~/Scripts//jquery.min.js"></script>
<script src="~/Scripts//jquery-ui.min.js"></script>
</head>
<body>
    @using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divID" }, new { @id = "fromID" }))
    {
        <div class="row">
            <div class="col-xs-12 col-md-3">
                <label>Input 1</label>
                @Html.TextArea("input1", "")
            </div>
            <div class="col-xs-12 col-md-3">
                <label>Input 2</label>
                @Html.TextArea("input2", "")
            </div>
            <div class="col-xs-12 col-md-3">
                <label>Input 3</label>
                @Html.TextBox("input3", "")
            </div>
            <div class="col-xs-12 col-md-3">
                <label>Input 4</label>
                @Html.TextBox("input4", "")
            </div>
        </div>
        <div>
            <input type="submit" value="Submit" class="btn btn-primary" />
        </div>
    }
</body>
</html>
```

## Replies

### Reply by Hemant Patel

Hi Ethan,

I have analyzed your code. As my point of view, you are not using **"jquery.unobtrusive-[ajax](https://www.mindstick.com/articles/1541/check-availability-of-user-name-or-email-using-asp-dot-net-ajax-and-jquery).min.js"** Ajax library in your project.

Modified your code as follows. But don't forget to use **"jquery.unobtrusive-ajax.min.js"** in your project.

```
<html>
<head>
    <link rel="stylesheet" href="~/Content/bootstrap.min.css">
    <link rel="stylesheet" href="~/Content/font-awesome.min.css">
    <script src="~/Scripts//jquery.min.js"></script>
    <script src="~/Scripts//jquery-ui.min.js"></script>
    <script src="~/Scripts/jquery.unobtrusive-ajax.min.js"></script>
</head>
<body>
    @using (Ajax.BeginForm("Action", "Controller", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "divID" }, new { @id = "fromID" }))
    {
        <div class="row">
            <div class="col-xs-12 col-md-3">
                <label>Input 1</label>
                @Html.TextArea("input1", "")
            </div>
            <div class="col-xs-12 col-md-3">
                <label>Input 2</label>
                @Html.TextArea("input2", "")
            </div>
            <div class="col-xs-12 col-md-3">
                <label>Input 3</label>
                @Html.TextBox("input3", "")
            </div>
            <div class="col-xs-12 col-md-3">
                <label>Input 4</label>
                @Html.TextBox("input4", "")
            </div>
        </div>
        <div>
            <input type="submit" value="Submit" class="btn btn-primary" />
        </div>
    }
</body>
</html>
```

I hope it's informative for you !!!


---

Original Source: https://www.mindstick.com/forum/34430/how-to-prevent-page-refresh-on-ajax-request

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
