Skip to content

Instantly share code, notes, and snippets.

@hatone
Created May 28, 2012 00:36
Show Gist options
  • Select an option

  • Save hatone/2816540 to your computer and use it in GitHub Desktop.

Select an option

Save hatone/2816540 to your computer and use it in GitHub Desktop.
ajax.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script>
//write here
$(function() {
$("input#search").click( function() {
var searchId = $("input#input_id").val();
$.get("json.php?id="+searchId, function(e) {
$("#nameDisp").html(e['name']);
$("#mailDisp").html(e['mail']);
$("#telDisp").html(e['tel']);
});
});
});
</script>
</head>
<body>
<input type="text" name="id" id="input_id" value="1"/>
<input type="button" id="search" value="検索" />
<table id="info">
<tr><th>name</th><th>mail</th><th>tel</th></tr>
<tr><td id="nameDisp"></td><td id="mailDisp"></td><td id= "telDisp"></td></tr>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment