# Pass URL to controllers via XMLHttpRequest

**URL:** https://forum.getkirby.com/t/pass-url-to-controllers-via-xmlhttprequest/25405
**Category:** Questions
**Tags:** v3
**Created:** [May 4, 2022, 10:26am UTC](https://forum.getkirby.com/t/pass-url-to-controllers-via-xmlhttprequest/25405 "2022-05-04T10:26:32Z")
**Posts on this page:** 1
**Showing post:** 3

<div class="post-metadata">

### Author: ![theamnesic](https://dub1.discourse-cdn.com/flex017/user_avatar/forum.getkirby.com/theamnesic/32/11855_2.png) [@theamnesic](https://forum.getkirby.com/u/theamnesic)
#### Post date: [May 4, 2022, 1:54pm UTC](https://forum.getkirby.com/t/pass-url-to-controllers-via-xmlhttprequest/25405/3 "2022-05-04T13:54:50Z")

</div>

> [@texnixe](#):
>
> You route cannot work, should be
> 
> ```auto
> 'pattern' => 'addbookmark/(:any)/(:any)/(:any)',
> 
> ```

Same with `:any`, 404 due to URL encoding 🙁

> [@texnixe](#):
>
> What is your controller actually doing?  
> Wondering why you are not sending a POST request to the controller (or add a json representation controller) instead of going via a route

BUT, got it thanks to you!

As `overcat` in [this post](https://forum.getkirby.com/t/controller-for-a-snippet/19518/8), my mistake was to POST directly to the controller like this :

```auto
xhttp.open("POST", "/site/controllers/add.php", true);

```

But the good way is to call the url obviously :

```auto
xhttp.open("POST", "/add", true);

```

My XHR request is solved ✅

About the inability to use URL in routes, I don’t know, it’s a bug or a feature?

Thanks!

---

_[View the full topic](https://forum.getkirby.com/t/pass-url-to-controllers-via-xmlhttprequest/25405)._
