Created
March 3, 2013 07:29
-
-
Save andrewvc/5075190 to your computer and use it in GitHub Desktop.
A CodePen by Andrew Cholakian.
This file contains 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
#command-bar | |
%form#client | |
.labels | |
%label#ajax-method-label{for: "method"} Method | |
%label#server-label{for: "server"} Server | |
%label#path-label{for: "Path"} Path | |
.fields | |
%select#ajax-method{name: "method"} | |
%option{value: "GET"} GET | |
%option{value: "PUT"} PUT | |
%option{value: "POST"} POST | |
%option{value: "DELETE"} DELETE | |
%input#server{type: "text", name: "server", value: "http://localhost:9200"} | |
%input#path{type: "text", name: "path"} | |
%input{type: "submit"} | |
#body | |
Body | |
%textarea | |
#response | |
Response | |
%textarea |
This file contains 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
$('#client').on('submit', function (e) { | |
e.preventDefault(); | |
var $f = $('#client'); | |
var meth = $f.find('#ajax-method').val(); | |
var srv = $f.find('#server').val(); | |
var path = $f.find('#path').val() | |
var url = srv + '/' + path; | |
$.ajax(url, {type: meth, dataType: 'text'}). | |
success(function (d) { | |
console.log(d); | |
$('#response textarea').text(d); | |
}).error(function (d) { | |
console.error(d); | |
$('#response textarea').text(d); | |
}); | |
}); |
This file contains 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
@import "compass"; | |
body { | |
font-family: Helvetica, Arial, sans-serif; | |
} | |
#command-bar { | |
display: table; | |
width: 920px; | |
.labels, .fields { | |
width: 920px; | |
display: table-row; | |
input, select, label { | |
display: inline-block; | |
padding: 2px 3px; | |
margin: 0px 5px; | |
}; | |
#ajax-method,#ajax-method-label { | |
width: 80px; | |
} | |
#server, #server-label { | |
width: 200px; | |
} | |
#path, #path-label { | |
width:500px; | |
} | |
} | |
} | |
#body, #response { | |
display: inline-block; | |
width: 450px; | |
height: 500px; | |
textarea { | |
display: block; | |
width: 100%; | |
height: 100%; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment