-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalized ajax, allows json etc #5
base: master
Are you sure you want to change the base?
Conversation
In the first version of this PR, the only HTTP method allowed was POST. This was obviously just an oversight. :-) That's now fixed in f4d9651. This also adds an instance for I now have an application (the old "todo" standby) working with ajax calls to a REST API. (The API was originally developed for an Ember implementation, so it's at least vaguely realistic.) Sample ajax calls from this application look reasonable to me:
|
looks pretty good to me, but I don't like the defaulting. Is it that mark On Sun, Mar 15, 2015 at 4:51 AM Toby Goodwin [email protected]
|
Yes, you're right. (I did say it was ugly!) That's tidied up now. I've made And then peering at the diff, I noticed that I was ignoring Hmm... should we allow |
Similar in spirit to the PR of @mwotton, this generalizes ajax with a ToAjax class. Instances allow the request body to be a list of pairs (as in the original code), or a String, a Text, or an aeson Object. A suitable default content type is chosen depending on the type of the data; it can be overridden in AjaxSettings. The response can be a string or an object, and is returned as an aeson Value. Obviously this does introduce a dependency on aeson, but since ghcjs-base depends on aeson I don't see a problem with this.
I've made a yesod-based test framework for ghcjs-jquery ajax calls: https://github.com/TobyGoodwin/ghcjs-jquery-test (It's fairly minimal so far; I'm happy to accept PRs, and of course track any changes that go into ghcjs-jquery.)