【发布时间】:2012-03-16 04:07:04
【问题描述】:
我有两个包含 js 代码的 html 文件(用于添加和编辑)。这两个文件是相同的,只是其功能中只有几行 js。实际上我不喜欢这两个文件都有共同的代码。有没有好办法处理这种情况?
例子:
(文件一)
<html>
<title>title goes here</title>
<javascript>
$('#button1').click(function () {
$.ajax({
type: "POST",
url: '/admin/test/checkcode',
data: {code:code, id:id}, // in here there is an id
async: false,
success: function(data){
}
});
}
</script>
<body>
</body>
</html>
(文件二)
<html>
<title>title goes here</title>
<javascript>
$('#button1').click(function () {
$.ajax({
type: "POST",
url: '/admin/test/checkcode',
data: {code:code}, // in here there is no id
async: false,
success: function(data){
}
});
}
</script>
<body>
</body>
</html>
【问题讨论】:
标签: javascript jquery html ajax xhtml