Simple HTML front end for playing with elastc

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Simple HTML front end for playing with elastc

zohar
here is a simple static page we use to play with the elastic server - can do both put & get but a simple as can be at the moment...  
Only dependency is from loading jquery from goggle.

Thought this may be useful for peeps.


<html>
<head>
    <script type="text/javascript" src="http://www.google.com/jsapi"></script>    <script type="text/javascript"> google.load("jquery", "1.4.4"); google.setOnLoadCallback(function() { $('#post').click(function() { $.ajax({ url:$('#post_url').val(), dataType:'json', type:$('#request_type').val(), data:$('#body').val(), success:function(data) { console.log(JSON.stringify(data)); $('#jsonResult').html(JSON.stringify(data, null, '\t')); }, error:function(xhr) { console.log(arguments); $('#jsonResult').html(JSON.stringify(xhr.responseText)); } }); }); }); </script></head>
<body>

<select id='request_type'>
    <option value="post">Post</option>
    <option value="get">Get</option>
</select>

<input type="text" id="post_url" size="80" value="http://localhost:9200/"> <br/>
<textarea id="body" rows="20" cols="80"></textarea>
<input id='post' type="button" value="Go">

        <pre id="jsonResult">
        </pre>
</body>
</html>
Reply | Threaded
Open this post in threaded view
|

Re: Simple HTML front end for playing with elastc

zohar
Fixed a buggette ->  must remove white space before posting or es gets angry....

<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
<script type="text/javascript"> $(document).ready(function() { $('#post').click(function() { $.ajax({ url:jQuery.trim($('#post_url').val()), dataType:'json', type:$('#request_type').val(), data:$('#body').val(), success:function(data) { console.log(JSON.stringify(data)); $('#jsonResult').html(JSON.stringify(data, null, '\t')); }, error:function(xhr) { console.log(arguments); $('#jsonResult').html(JSON.stringify(xhr.responseText)); } }); }); }); </script></head>
<body>

<select id='request_type'>
<option value="post">Post</option>
<option value="get">Get</option>
</select>

<input type="text" id="post_url" size="80" value="http://localhost:9200/"> <br/>
<textarea id="body" rows="20" cols="80"></textarea>
<input id='post' type="button" value="Go">

<pre id="jsonResult">
</pre>
</body>
</html>