AJAX post with handler in orchard

Oct 21, 2010 at 9:23 AM

Does anybody have some samle code that will explain how I can do an ajax post to a handler in orchard which will then save the data to database and have this data viewable through a page in the admin as a list and then individual item details when selected from the list?

Oct 21, 2010 at 5:06 PM

You would do that exactly the same way you'd do it with plain MVC: you'll need a routed controller action to handle the requests and that action can return a Json action result. The only thing that might be a little different is how you'd include your script on the page. There is a new registration API for that in Orchard 0.8 (released next Monday).

Oct 25, 2010 at 5:26 AM

Thank you Bertrand, I managed to get the AJAX bits working but am however struggling with saving the posted values to orchard db. I have used the codegen to create a content type but those bits are not working. Does anybody have a real world end to end example with source code as this will go far in explaining the orchard module dev for me and I am sure a few others out there as well. I have tried to string together some of the code from the modules already in orchard but they are specific to the topics they are written for and are confusing me even more in a simple module which I am trying to achieve. Until such time as the documentation is up to date it is very frustrating to get anything working as they do not address the requirements. What is further frustrating me is that 0.5 was a module developer release yet a lot has changed in 0.8 as I tried to run code that was working in 0.5 in 0.8 without success.

Oct 25, 2010 at 5:44 AM

Well, sorry about the frustration. There are bits that changed in module development: what was dealing with UI, and that's quite a lot, but that was expected. We are working on the documentation right now, in particular upgrading existing topics for 0.8. I''ll make sure to add downloads for code samples where relevant.