# Custom menu with an AJAX call

**URL:** <https://meta.discourse.org/t/custom-menu-with-an-ajax-call/76267>\
**Category:** Development\
**Created:** [12월 17, 2017, 5:49오후 UTC](https://meta.discourse.org/t/custom-menu-with-an-ajax-call/76267 "2017-12-17T17:49:00Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![Happy](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/happy/32/84237_2.png) [@Happy](https://meta.discourse.org/u/Happy)\
**Post date:** [12월 18, 2017, 3:24오후 UTC](https://meta.discourse.org/t/custom-menu-with-an-ajax-call/76267/3 "2017-12-18T15:24:38Z")

</div>

You’re right 🙂

Here’s the code I have a mistake with.

```
export default createWidget('discourse-custom-header', {
    tagName: 'div',

    html() {
        return $.when($.ajax({
            url: 'http://www.example.com/menu',
            async: false
        })).then(result => {
            return [
                h('div', [
                    new RawHtml({ html: `${result}` })
                ])
            ];
        });
    }
});

```

I get this warning

[Deprecation] Synchronous XMLHttpRequest on the main thread is deprecated because of its detrimental effects to the end user’s experience. For more help, check [https://xhr.spec.whatwg.org/](https://xhr.spec.whatwg.org/).

and this error

```
Error: Unexpected virtual child passed to h().
Expected a VNode / Vthunk / VWidget / string but:
got:
{}.
The parent vnode is:
{
    "tagName": "DIV",
    "properties": {
        "attributes": {},
        "className": "custom-menu"
    }
}

```

---

_[View the full topic](https://meta.discourse.org/t/custom-menu-with-an-ajax-call/76267)._
