zoukankan      html  css  js  c++  java
  • ajax 异步调用把返回值赋给一个全局变量的用法,最主要的就是把async属性改为 false,


    <script>

    $(document).ready(function () {
    <%
    string dqsj = System.DateTime.Now.ToString("yyyy-MM-dd");
    %>
    seach();

    });
    var shuju = "";
    var sj = "";
    function se()
    {
    seach();
    }
    function seach() {
    $(function () {
    var strTady = $("#txtCxsj").val();
    $.ajax({
    async: false,
    type: "POST",
    url: "/qbjl/dqwdxx?strTady=" + strTady,
    dataType: 'json',
    success: function (data) {
    shuju = data.rows;
    sj = data.rows1;
    }
    });
    $('#container').highcharts({
    chart: {
    zoomType: 'xy',
    plotBackgroundImage: '/Yxjc/xml/themebg.png',
    backgroundColor: '#e9ecef'
    },
    credits: {
    enabled: false // 禁用版权信息
    },
    title: {
    text: '大气温度数据展示'
    },
    xAxis: [{
    categories: eval(sj)
    }],
    yAxis: [
    { // Secondary yAxis
    gridLineWidth: 0,
    title: {
    text: '大气温度',
    style: {
    color: Highcharts.getOptions().colors[0]
    }
    },
    labels: {
    format: '{value} ℃',
    style: {
    color: Highcharts.getOptions().colors[0]
    }
    }

    }
    ],
    tooltip: {
    shared: true
    },
    legend: {
    layout: 'vertical',
    align: 'center',
    x: 350,
    verticalAlign: 'top',
    y: 15,
    floating: true,
    backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
    },

    series: [{

    name: '大气温度',
    data: eval(shuju)

    }]

    });
    });
    }
    function IsTady() {
    strTady = $("#txtCxsj").val();
    var strsj = new Date();
    var strrq = strsj.format("yyyy-MM-dd");
    if (strTady != "") {
    if (strTady < strrq) {
    $("#NextBtn").show();
    }
    else {
    $("#NextBtn").hide();
    }
    }
    }
    function BackDay() {
    strTady = $("#txtCxsj").val();
    if (strTady != "") {
    var day = new Date(Date.parse(strTady.replace(/-/g, '/')));
    day.setDate(day.getDate() - 1);

    $("#txtCxsj").val(day.format("yyyy-MM-dd"));
    seach();
    }
    else {
    alert("查询日期不能为空");
    }

    }
    function NextDay() {
    strTady = $("#txtCxsj").val();
    if (strTady != "") {
    var day = new Date(Date.parse(strTady.replace(/-/g, '/')));
    day.setDate(day.getDate() + 1);
    $("#txtCxsj").val(day.format("yyyy-MM-dd"));
    seach();
    }
    else {
    alert("查询日期不能为空");
    }
    }

    Date.prototype.format = function (format) {
    var o = {
    "M+": this.getMonth() + 1,
    "d+": this.getDate(),
    "h+": this.getHours(),
    "m+": this.getMinutes(),
    "s+": this.getSeconds(),
    "q+": Math.floor((this.getMonth() + 3) / 3),
    "S": this.getMilliseconds()
    }
    if (/(y+)/.test(format)) {
    format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    }
    for (var k in o) {
    if (new RegExp("(" + k + ")").test(format)) {
    format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    }
    }
    return format;
    }
    </script>
    <div class="box2" paneltitle="选择指针喷灌机" id="searchPanel">
    <form action="" id="queryForm" method="post">
    <input type="hidden" id="parentId" name="parentId" value="1" />
    <table cellpadding="0" cellspacing="0" width="100%" class="table">
    <tr>
    <td class="ti_blue" width="70" style="text-align: right">查询日期:
    </td>
    <td width="150">

    <input type="text" class="date" id="txtCxsj" datefmt="yyyy-MM-dd" name="gcjcxx.jcny" onpropertychange="IsTady()" value="<%=dqsj%>" />

    </td>
    <td class="ti_blue" width="220" style="text-align: left">

    <button type="button" onclick="BackDay()"><span class="icon_find">上一天</span></button>&nbsp;
    <button type="button" onclick="NextDay()" id="NextBtn" style="display: none"><span class="icon_find">下一天</span></button>
    </td>
    <td align="right" style="padding-right: 10px">

    <button type="button" onclick="se()"><span class="icon_find">查询</span></button>
    </td>
    </tr>
    </table>
    </form>
    </div>
    <div style="border:solid 1px #bcf5f5">
    <div id="container" style="min-700px;height:400px;"></div>
    </div>
    <div style="height:0px; 100%;"></div>

  • 相关阅读:
    IOS开发之——绘图(CGContext)
    网站相关人员信息记录humans.txt
    统一代码风格工具——editorConfig
    Bootstrap自动定位浮标
    Bootstrap图片轮播
    Bootstrap手风琴效果
    Bootstrap按钮插件
    Bootstrap弹出框
    Bootstrap提示框
    Bootstrap选项卡
  • 原文地址:https://www.cnblogs.com/zcwry/p/we.html
Copyright © 2011-2022 走看看