Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
//前後のコードは省略
//HTMLのコード
string HTML_BODY =
"<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<style type='text/css'>
body, input, button {
font-family: tahoma, arial, 'hiragino kaku gothic pro', meiryo, 'ms pgothic', sans-serif;
zoom: 200%;
}
</style>
<script>
$(function() {
$('button').click(function() {
var content = {};
content.text = $('#input').val();
content.click = $(this).attr('id');
if (content.text != '') {
$('#input').val('');
$.ajax({
'type': 'POST',
'url': location.href,
'dataType': 'json',
'data': JSON.stringify(content)
}).done(function(data) {
$('#output').html(data.text).css(data.style);
});
}
});
});
</script>
</head>
<body>
<div id='output'>ajaxのサンプル</div>
<p><input id='input' style='width:100%;'></p>
<button id='btn1'>赤で表示</button>
<button id='btn2'>青で表示</button>
</body>
</html>
";
//前後のコードは省略
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment