码迷,mamicode.com
首页 > 其他好文 > 详细

ajax 异步调用把返回值赋给一个全局变量的用法,最主要的就是把async属性改为 false,

时间:2014-08-21 16:47:14      阅读:260      评论:0      收藏:0      [点我收藏+]

标签:style   color   os   io   for   数据   ar   art   


<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-width:700px;height:400px;"></div>
</div>
<div style="height:0px; width:100%;"></div>

ajax 异步调用把返回值赋给一个全局变量的用法,最主要的就是把async属性改为 false,,布布扣,bubuko.com

ajax 异步调用把返回值赋给一个全局变量的用法,最主要的就是把async属性改为 false,

标签:style   color   os   io   for   数据   ar   art   

原文地址:http://www.cnblogs.com/zcwry/p/we.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!