html
  head
    meta(charset='utf-8')
    |     
    script(type='text/javascript', src='http://libs.baidu.com/jquery/2.1.4/jquery.min.js')
  body
    #myDiv
      h2 ajax
    |     
    button#b01(type='button') testajax
    |     
    table#tsTable
      thead
        tr
          th(data-options="field:'DATE',width:180,align:'center'") DATE/时间
          |                 
          th(data-options="field:'PRE_CLOSE',width:180,align:'center'") PRE_CLOSE前收盘价
          |                 
          th(data-options="field:'OPEN',width:180,align:'center'") OPEN
          |                 
          th(data-options="field:'HIGH',width:180,align:'center'") HIGH
          |                 
          th(data-options="field:'LOW',width:180,align:'center'") LOW
          |                 
          th(data-options="field:'CLOSE',width:180,align:'center'") CLOSE
          |                 
          th(data-options="field:'VOL',width:180,align:'center'") VOL
    |     
    script.
      function changeToButton(id){
      var btn = document.getElementById(id);
      btn.onclick= function(){
      $.ajax({
      url: "http://localhost:3030/querybyid",    //请求的url地址
      dataType: "json",   //返回格式为json
      async: true, //请求是否异步，默认为异步，这也是ajax重要特性
      data: { "name": "600005_ts" },    //参数值
      type: "GET",   //请求方式
      beforeSend: function() {
      //请求前的处理
      //alert('before');
      },
      success: function(data,textStatus){

        alert('textStatus---'+textStatus)
        alert(JSON.stringify(data));
        var append=JSON.stringify(data);
        //$('#myDiv').prepend(append);
        alert(JSON.parse(append)[0].OPEN)
        var table = $('#tsTable');
        var html = '<tr>';
      //  var list = data.list;
        alert(JSON.parse(append).length)
        var dats=JSON.parse(append);
        var html = '<tr>'
        for (var i = 0, len = dats.length; i < len; i++) {
          alert(dats[i].DATE)
          html += '<td>'+dats[i].DATE+dats[i].PRE_CLOSE+dats[i].OPEN+dats[i].HIGH+dats[i].LOW+dats[i].CLOSE+dats[i].VOLUME+'</tr>'; 
        }
        html += '</tr>';
       
        html.appendTo($('#tsTable'));
      },
      complete: function() {
      //请求完成的处理
      alert('complete');
      },
      error: function() {
      //请求出错处理
      alert('error');
      }
      });
      }
      }
      window.onload = function() {
      changeToButton("b01");
      }
