-
Notifications
You must be signed in to change notification settings - Fork 0
/
create_request.js
26 lines (24 loc) · 969 Bytes
/
create_request.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
if (typeof pwc == 'undefined'){
pwc = {};
};
pwc.CreateRequest = function(root_selector, get_callback){
this.root_selector = root_selector;
this.root = $(root_selector);
this.get_callback = get_callback;
this.parameter_list = new pwc.ItemList(root_selector + " #parameters");
this.header_list = new pwc.ItemList(root_selector + " #headers");
};
pwc.CreateRequest.prototype.setup_events = function(){
var _this = this;
$(this.root_selector + " #submit_request").live("click", function(){
var url = _this.root.find("#url").val();
var method = _this.root.find("#method").val();
var parameters = $.toJSON(_this.parameter_list.parameters);
var headers = $.toJSON(_this.parameter_list.headers);
var response_get = $.post("/request", {"url": url, "method": method,
"parameters": parameters, "headers": headers});
_this.get_callback(response_get);
});
this.parameter_list.setup_events();
this.header_list.setup_events();
};