File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
rest_framework_docs/static/rest_framework_docs/js Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -56,18 +56,28 @@ $( document ).ready(function() {
5656 $ ( '#responseData' ) . html ( jsonPP . prettyPrint ( response . responseJSON ) ) ;
5757 } ;
5858
59+ var getFormData = function ( ) {
60+ var data = { } ;
61+
62+ $ ( '#fields .form-group' ) . each ( function ( ) {
63+ var input = $ ( this ) . find ( 'input' ) ;
64+ var name = input . attr ( 'id' ) ;
65+ var value = input . val ( ) ;
66+ data [ name ] = value ;
67+ } )
68+
69+ return data ;
70+ } ;
71+
5972 var makeRequest = function ( ) {
6073 var url = $ ( '#requestForm #urlInput' ) . val ( ) ;
6174 var method = $ ( "#methods" ) . find ( ".active" ) . text ( ) ;
62-
75+ var data = getFormData ( ) ;
6376 $ . ajax ( {
6477 url : url ,
6578 method : method ,
6679 context : document . body ,
67- data : {
68- username : 'test' ,
69- password : 'test'
70- }
80+ data : data
7181 } ) . always ( function ( response ) {
7282 setResponse ( method , response ) ;
7383 } ) ;
@@ -100,7 +110,7 @@ $( document ).ready(function() {
100110 '<div class="form-group">' +
101111 '<label for="field' + field . name + '" class="col-sm-4 control-label">' + label + '</label>' +
102112 '<div class="col-sm-8">' +
103- '<input type="text" class="form-control input-sm" id="field ' + field . name + '" placeholder="' + field . type + '">' +
113+ '<input type="text" class="form-control input-sm" id="' + field . name + '" placeholder="' + field . type + '">' +
104114 '</div>' +
105115 '</div>' +
106116 "" ) ;
You can’t perform that action at this time.
0 commit comments