bigbluebutton-Github/labs/bbb-html5-client/public/js/utils.coffee

30 lines
895 B
CoffeeScript

define [
'underscore',
'backbone'
], (_, Backbone) ->
Utils = {}
# POST request using javascript
# @param {string} path path of submission
# @param {string} params parameters to submit
# @param {string} method method of submission ("post" is default)
# @return {undefined}
Utils.postToUrl = (path, params, method) ->
method = method or "post"
# TODO: can be a lot cleaner with jQuery
form = document.createElement("form")
form.setAttribute "method", method
form.setAttribute "action", path
for key of params
if params.hasOwnProperty(key)
hiddenField = document.createElement("input")
hiddenField.setAttribute "type", "hidden"
hiddenField.setAttribute "name", key
hiddenField.setAttribute "value", params[key]
form.appendChild hiddenField
document.body.appendChild form
form.submit()
Utils