Ajax asynchronous calls assign the return value to a global variable. The most important thing is to change the async attribute to false,

Source: Internet
Author: User


<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;
}
});
$ ('# Iner'). highcharts ({
Chart :{
Zoomtype: 'xy ',
Plotbackgroundimage: '/yxjc/XML/themebg.png ',
Backgroundcolor: '# e9ecef'
},
Credits :{
Enabled: false // disable copyright information
},
Title :{
Text: 'atmospheric temperature data display'
},
Xaxis :[{
Categories: eval (SJ)
}],
Yaxis :[
{// Secondary yaxis
Gridlinewidth: 0,
Title :{
Text: 'atmospheric temperature ',
Style :{
Color: highcharts. getoptions (). colors [0]
}
},
Labels :{
Format: '{value} ℃ ',
Style :{
Color: highcharts. getoptions (). colors [0]
}
}

}
],
Tooltip :{
Shared: True
},
Legend :{
Layout: 'signature ',
Align: 'center ',
X: 350,
Verticalalign: 'top ',
Y: 15,
Floating: True,
Backgroundcolor: (highcharts. Theme & highcharts. theme. legendbackgroundcolor) | '# ffff'
},

Series :[{

Name: 'atmospheric temperature ',
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 ("query date cannot be blank ");
}

}
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 ("query date cannot be blank ");
}
}

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"> query Date:
</TD>
& Lt; TD width = "150" & gt;

<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"> last day </span> </button> & nbsp;
<Button type = "button" onclick = "nextday ()" id = "nextbtn" style = "display: none "> <SPAN class =" icon_find "> next day </span> </button>
</TD>
<TD align = "right" style = "padding-Right: 10px">

<Button type = "button" onclick = "Se ()"> <SPAN class = "icon_find"> query </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>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.