# Moving from Sage 9 to Sage 10: ReferenceError: ajaxArticle is not defined

**URL:** https://discourse.roots.io/t/moving-from-sage-9-to-sage-10-referenceerror-ajaxarticle-is-not-defined/27727
**Category:** sage
**Tags:** sage10
**Created:** 2024-07-04T09:50:49Z
**Posts:** 2
**Showing post:** 2 of 2

## Post 2 by @Tetrahedrax — 2024-07-04T11:20:21Z

Ok so after much hair tearing, I figured it out. You can’t bundle it the way I did in the setup.php. You have to do it like this:

`bundle('article')->localize('ajaxArticle', ['ajaxURL' => admin_url('admin-ajax.php')]);`

The next error I encountered immediately afterwards was due to ajax not being added to the collect in functions.php. Same thing as the guy here:

> [@Sage 10 Ajax Bad Request](https://discourse.roots.io/t/sage-10-ajax-bad-request/25747):
>
> Hello, I am setting up ajax with my Sage 10 project. I keep getting a 400 Bad Request error. I have done this on many projects before but never with sage 10. I’ve searched the forum and many other resources and can’t seem to figure out what my problem is. My files are as follows: app/setup.php - localizing ajax\_url add\_action('wp\_enqueue\_scripts', function () { global $post; bundle('app')-\>enqueue()-\>localize('wcu', [ 'ajax\_url' =\> admin\_url('admin-ajax.php'), 'nonce…

Basically, you have to change collect to this:  
`collect(['setup', 'filters', 'ajax'])`

Hopefully this will help the next dummy trying to port Sage 9 to Sage 10!

---

_[View the full topic](https://discourse.roots.io/t/moving-from-sage-9-to-sage-10-referenceerror-ajaxarticle-is-not-defined/27727)._
