H5调用js代码

来源:互联网 发布:两张表格重复数据筛选 编辑:程序博客网 时间:2024/05/07 20:30

工具sublime


<!DOCTYPE html>

<html lang="zh-Hans">
<head>
//<title>gary demos</title>


<!-- 包含引用文件“jquery-3.1.0.imn.js" 需要先有这个文件-->
<script type="text/javascript" src="jquery-3.1.0.min.js"></script>
<script type="text/javascript">


// js函数 。用jquery调用ajax
function garyfun(){
//http://wx224d24fedead56ee.opendev.guangguang.net.cn/jigsaw_puzzle/jigsaw_puzzle/index/game_confirm

$.ajax( {
url:'http://wx224d24fedead56ee.opendev.guangguang.net.cn/jigsaw_puzzle/jigsaw_puzzle/index/game_confirm',
  type: 'GET',
  data: {},//传出的数据
  dataType: 'json',
  contentType: 'application/json',
  timeout: 3000,
  success: function(response) {
  alert(response)
  // console.log(response.something);
  },
  error: function(request, errorType, errorMessage) {
  // console.log("[" + errorType + "] " + errorMessage);
  },
  beforeSend: function() {
  // do something like .addClass('is-fetching')
  },
  complete: function() {
  //do something like removeClass('is-fetching')
  }
});
}
</script>
</head>
<body background="IMG_20171023_122117.jpg">
<h1>Set background color</h1>


//通过按钮点击调用js函数
    <button onclick="garyfun()">touch me</button>
    

</body>

</html>


//http://www.jb51.net/article/62703.htm  参考出处