ajax 非同步呼叫把傳回值賦給一個全域變數的用法,最主要的就是把async屬性改為 false,

來源:互聯網
上載者:User

標籤: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>

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.