Created
September 5, 2014 02:09
-
-
Save agibsonccc/a80bc984902d8bb8bcc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $.fn.serializeObject = function() | |
| { | |
| var o = {}; | |
| var a = this.serializeArray(); | |
| $.each(a, function() { | |
| if (o[this.name] !== undefined) { | |
| if (!o[this.name].push) { | |
| o[this.name] = [o[this.name]]; | |
| } | |
| o[this.name].push(this.value || ''); | |
| } else { | |
| o[this.name] = this.value || ''; | |
| } | |
| }); | |
| return o; | |
| }; | |
| $(document).ready(function() { | |
| var api = new $.RestClient('/api/'); | |
| api.add('similarity',{ | |
| stringifyData : true | |
| }); | |
| api.add('analogy',{ | |
| stringifyData : true | |
| }); | |
| $('#analogy_submit').click(function(e) { | |
| e.preventDefault(); | |
| var serialized = $('#analogy').serializeObject(); | |
| api.analogy.create(serialized).done(function(data) { | |
| console.log(data); | |
| }); | |
| }); | |
| $('#sim_submit').click(function(e) { | |
| e.preventDefault(); | |
| var serialized = $('#similarity').serializeObject(); | |
| api.similarity.create(serialized).done(function(data) { | |
| console.log(data); | |
| }); | |
| }); | |
| }); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment