---
title: "What are the common data-ajax-* attributes used in an AJAX-enabled form, and what do they do?"  
description: "What are the common data-ajax-* attributes used in an AJAX-enabled form, and what do they do?"  
author: "Anubhav Sharma"  
published: 2025-07-28  
updated: 2025-08-05  
canonical: https://www.mindstick.com/forum/161833/what-are-the-common-data-ajax-attributes-used-in-an-ajax-enabled-form-and-what-do-they-do  
category: "asp.net mvc"  
tags: ["mvc", "ajaxform"]  
reading_time: 2 minutes  

---

# What are the common data-ajax-* attributes used in an AJAX-enabled form, and what do they do?

**What are the [common](https://www.mindstick.com/articles/23170/10-most-common-accounting-mistakes-of-small-business)** `data-ajax-*` **[attributes](https://www.mindstick.com/articles/13105/2-attributes-that-make-your-odoo-ecommerce-theme-productive-and-engaging) used in an AJAX-enabled form, and what do they do?**

- For example: `data-ajax`, `data-ajax-method`, `data-ajax-update`, etc.

## Replies

### Reply by ICSM Computer

**Theoretical overview** of the commonly used `data-ajax-*` attributes in an [**Ajax.BeginForm** -enabled form in **ASP.NET MVC**](https://www.mindstick.com/interview/34342/how-does-the-ajax-beginform-helper-work-in-asp-dot-net-mvc):

### Common `data-ajax-*` Attributes

| Attribute | Purpose |
| --- | --- |
| `data-ajax="true"` | Enables AJAX submission for the form. Required to activate the feature. |
| `data-ajax-method` | HTTP method to use (`GET`, `POST`, etc.). Default is `GET`. |
| `data-ajax-mode` | How to insert the response (`replace`, `before`, `after`). |
| `data-ajax-update` | CSS selector (e.g., `#divId`) to inject the response HTML into. |
| `data-ajax-url` | Optional URL to override form action for the request. |
| `data-ajax-begin` | JavaScript function called before the AJAX request is sent. |
| `data-ajax-success` | JS function called when the request succeeds. |
| `data-ajax-failure` | JS function called when the request fails. |
| `data-ajax-complete` | JS function called after request completes (success or failure). |
| `data-ajax-loading` | Selector for an element to show/hide during the AJAX request. |
| `data-ajax-confirm` | Shows a confirmation dialog before sending the request. |

### Example

```html
<form data-ajax="true"
      data-ajax-method="POST"
      data-ajax-update="#resultDiv"
      data-ajax-mode="replace"
      data-ajax-success="onSuccess"
      data-ajax-failure="onFailure"
      data-ajax-begin="onBegin">
    ...
</form>
```

### Behind the Scenes

- These attributes are processed by `jquery.unobtrusive-ajax.js`, which:
- Hooks form submission
- Sends AJAX request using jQuery
- Injects response into specified element


---

Original Source: https://www.mindstick.com/forum/161833/what-are-the-common-data-ajax-attributes-used-in-an-ajax-enabled-form-and-what-do-they-do

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
