Zend Framework with ajax friendly settings

advertisements

I'm building a REST API with Zend Framework. I have routes setup that are mapped to all the resources I modeled. I also created a RESTful controller plugin to direct the different types of requests (PUT, GET, etc..) to the right controller action.

I'm making ajax calls with jQuery and by default it appends GET parameters to the URL for the ajax call. I want to pass along these parameters as filters on my resources.

How can I get Zend Framework to pass these parameters into my controllers? Hoping not to have to write a controller plugin to make this work...

Working URL

http://myapp.com/catalog/products/categories/max_results/20/start_index/5

What I Want

http://myapp.com/catalog/products/categories/?max_results=20&start_index=5

Zend Framework Route

routes.catalog_product_categories.type = "Zend_Controller_Router_Route"
routes.catalog_product_categories.route = "catalog/products/categories/*"
routes.catalog_product_categories.defaults.controller = "categories"
routes.catalog_product_categories.defaults.action = "productcategories"
routes.catalog_product_categories.defaults.RESTful = true


Maybe you may want to change your Ajax calls to force the parameters to be sent to the script:

$.get("/catalog/", { max_results: "20", start_index: "5" } );
$.post("/catalog/", { max_results: "20", start_index: "5" } );