A Pen by liuxiaomingskm on CodePen.
Last active
February 1, 2020 23:35
-
-
Save liuxiaomingskm/7fe739108bbd34cb195e1bc772e4448c to your computer and use it in GitHub Desktop.
练习了用JQUERY发送AJAX命令
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
<script | |
src="https://code.jquery.com/jquery-3.4.1.js" | |
integrity="sha256-WpOohJOqMqqyKL9FccASB9O0KwACQJpFTUBLTYOVvVU=" | |
crossorigin="anonymous"></script> | |
<button id="btn">click me</button> |
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
$('#btn').click(function(){ | |
$.ajax({ | |
method:"GET", | |
url:"https://baconipsum.com/api/?type=meat-and-filler", | |
dataType:'json' | |
}).done(function(data){ | |
console.log(data); | |
}) | |
.fail(function(){ | |
alert("Oh No!Failed~"); | |
}) | |
}); |
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
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment