Created
December 2, 2015 07:56
-
-
Save stmtk1/62fea90ae00a10085435 to your computer and use it in GitHub Desktop.
ajax test
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
a.html |
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
b.html |
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> | |
<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