Skip to content

Instantly share code, notes, and snippets.

@wuliupo
Last active August 29, 2015 14:03
Show Gist options
  • Save wuliupo/d20cc1482af5c1c9d1c2 to your computer and use it in GitHub Desktop.
Save wuliupo/d20cc1482af5c1c9d1c2 to your computer and use it in GitHub Desktop.
ScriptInAjax
<script type="text/javascript" src="event.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<script type="text/javascript">
function eventInScript(){
console.log("event In Script");
}
</script>
<style type="text/css">
.class-in-file{border: 1px solid #F00;}
</style>
成功加载点击按钮测试是否加载js
<button type="button" onclick="eventInFile();" class="class-in-file">event In File</button>
<button type="button" onclick="eventInScript();" class="class-in-style">event In Script</button>
function eventInFile(){
console.log("event In File");
}
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>ScriptInHTML</title>
</head>
<body>
<button type="button" onclick="loadData();" >click me to load data</button>
<div id="loading">Loading</div>
<script type="text/javascript" src="//code.jquery.com/jquery-latest.js"></script>
<script type="text/javascript">
function loadData(){
$.ajax({
url : "data.html",
success : function(result) {
//TODO how to rend the innerHTML ???
$("#loading").html(result);
}
});
}
</script>
</body>
</html>
.class-in-style{background-color: #F00;}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment