forum

Home / DeveloperSection / Forums / How to prevent page refresh on ajax request?

How to prevent page refresh on ajax request?

Anonymous User 1074 13-Mar-2018

Hi,

I have submitted the form through ajax request. But on submission of the form, the page was refresh.

Please give me some idea to prevent page refresh on form submit.

Here is my code,


<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>

Updated on 13-Mar-2018
I am a content writter !

Can you answer this question?


Answer

1 Answers

Liked By