Skip to content

Instantly share code, notes, and snippets.

@andrewvc
Created March 3, 2013 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewvc/5075190 to your computer and use it in GitHub Desktop.
Save andrewvc/5075190 to your computer and use it in GitHub Desktop.
A CodePen by Andrew Cholakian.
#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
$('#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);
});
});
@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