# How to pop up an error message in the front end with an Ajax request?

**URL:** https://meta.discourse.org/t/ajax/395532
**Category:** Development
**Created:** [February 9, 2026, 10:14am UTC](https://meta.discourse.org/t/ajax/395532 "2026-02-09T10:14:54Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![singi2016cn](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/singi2016cn/32/532755_2.png) [@singi2016cn](https://meta.discourse.org/u/singi2016cn)
#### Post date: [February 9, 2026, 10:14am UTC](https://meta.discourse.org/t/ajax/395532/1 "2026-02-09T10:14:54Z")

</div>

```plaintext
return render_json_error(
            'Cannot perform the pin operation.',
            status: 402
          )

```

Using the `render_json_error` method, how can I display an error message on the frontend?

---

<div class="post-metadata">

### Author: ![NateDhaliwal](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/natedhaliwal/32/313494_2.png) [@NateDhaliwal](https://meta.discourse.org/u/NateDhaliwal)
#### Post date: [February 9, 2026, 10:27am UTC](https://meta.discourse.org/t/ajax/395532/2 "2026-02-09T10:27:18Z")

</div>

I’m not sure what the whole context is, but I believe you can do this:

```js
import { ajax } from "discourse/lib/ajax";
import { popupAjaxError } from "discourse/lib/ajax-error";

try {
  // ...
} catch (e) {
  popupAjaxError(e);
}

// OR
ajax("...") // Some function
  .then(() => {
    // ...
  })
  .catch(popupAjaxError);

```

---

<div class="post-metadata">

### Author: ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)
#### Post date: [March 11, 2026, 10:27am UTC](https://meta.discourse.org/t/ajax/395532/3 "2026-03-11T10:27:50Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
