Skip to content

Instantly share code, notes, and snippets.

@stmtk1
Created December 2, 2015 07:56
Show Gist options
  • Save stmtk1/62fea90ae00a10085435 to your computer and use it in GitHub Desktop.
Save stmtk1/62fea90ae00a10085435 to your computer and use it in GitHub Desktop.
ajax test
<!DOCTYPE html>
<html>
<head>
<title>ajax test</title>
<meta charset="UTF-8">
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
</head>
<body>
<button id="click">click me</button>
<div id="result"></div>
<script>
var flag = false;
$('#click').click(function(){
if(flag == false){
$.ajax({
type: 'GET',
url: 'a.html',
dataType: 'html',
success: function(html){
$('#result').html(html);
flag = true;
}
});
}else if(flag == true){
$.ajax({
type: 'GET',
url: 'b.html',
dataType: 'html',
success: function(html){
$('#result').html(html);
flag = false;
}
});
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment