Last active
November 11, 2018 02:47
-
-
Save taitokiss/9116b61a914b27733c777dd2db04514b to your computer and use it in GitHub Desktop.
ajax 1つデータを送り、結果を表示
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Ajax Test1</title> | |
</head> | |
<body> | |
<button id="button">送信</button> | |
<div><br></div> | |
<div id="result">戻り値をここに表示します</div> | |
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script> | |
<script> | |
$(function(){ | |
$("#button").click(function(event){ | |
$.ajax({ | |
type: "GET", | |
url: "ajax_test1.php", | |
data: { val: 99 }, | |
dataType : "text" | |
}).done(function(data){ | |
$("#result").text(data); | |
}).fail(function(XMLHttpRequest, textStatus, errorThrown){ | |
alert(errorThrown); | |
}); | |
}); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment