-
-
Save masterpoppy/03fa6fd6800094cd5245850132c7ae58 to your computer and use it in GitHub Desktop.
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
//前後のコードは省略 | |
//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