# JavaScript

This part provides IActionResults and extension methods related to JavaScript and client-side things.

## JavaScriptResult

`JavaScriptResult` class serves as a simple wrapper for `ContentResult` with `ContentType` equals `application/javascript` and serves to transfer javascript code to client. It contains no additional fields, properties or logic.

## AjaxRedirectResult

This class represents the implementation of `RedirectResult` that checks that request has ajax nature and performs redirect to Url via ajax instead of normal redirecting. In case of normal request the standard redirecting procedure will be performed.

## JavaScriptController extensions

| Method name       | Return type          | Description                                                                                                                                                                                                      |
| ----------------- | -------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| JavaScript        | `JavaScriptResult`   | Creates a `JavaScriptResult` with specified content.                                                                                                                                                             |
| AjaxLocalRedirect | `AjaxRedirectResult` | Creates an instance of `AjaxRedirectResult` while checking if url is local. In case of local url the redirect is performed to specified `url`. Otherwise creates response for redirecting to application's root. |
| AjaxRedirect      | `AjaxRedirectResult` | Creates an instance of `AjaxRedirectResult` that checks that request has ajax nature and performs redirect to Url via ajax instead of normal redirecting.                                                        |


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.structr.dev/presentation/aspnetcore/javascript.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
