Echarts HTML parameter +JS request +ASHX Service Code mode

Source: Internet
Author: User
Tags html header

HTML Header Pass Method

<!DOCTYPE HTML><HTMLxmlns= "http://www.w3.org/1999/xhtml"><Head><Metahttp-equiv= "Content-type"content= "text/html; charset=utf-8"/>    <title></title>    <Scriptsrc= "/scripts/jquery-2.1.1.min.js"></Script>    <!--Echart -    <Scripttype= ' Text/javascript 'src= "/scripts/esl.js"></Script>    <Scripttype= ' Text/javascript 'src= "/scripts/echarts.js"></Script>    <Scriptsrc= "/scripts/main.js"></Script>    <Scriptsrc= "/scripts/realtimeview.js"></Script>
</Head><Body>    <Divclass= "Tab-pane"ID= "TaB2">        <DivID= "Tab1chart1"class= "Row"style= "height:300px"></Div>        <DivID= "Tab1chart2"class= "Row"style= "height:300px"></Div>    </Div></Body></HTML><Script>    $(function() {BTNR (); });</Script>

JS handles HTML parameters and requests to the background

vararg1;vararg2;varlocstring=String (WINDOW.DOCUMENT.LOCATION.HREF); functiongetquerystr (str) {varresult = Location.search.match (NewRegExp ("[\?\&]" + str + "= ([^\&]+)", "I")); if(Result = =NULL|| Result.length < 1) {        return""; }    returnResult[1];}//Get HTTP ParametersfunctionReceiveparameter () {arg1= Getquerystr ("Arg1"); Arg2= Getquerystr ("Arg2");}
$.ajax ({"DataType": ' JSON ',        ' type ': ' GET ', Async:false,        "url": '/info.ashx ',        "Data": {' arg1 ': arg1, "arg2": arg2},"Success":function(JSON) {if(JSON = =NULL) {mychart1.showloading ({//return data is emptyText: ""                }); return; } options.xaxis[0].data =json.category; Options.series=json.series; Options.legend.data=Json.legend; Options.title.text= ' curve ';            Mychart1.hideloading ();        Mychart1.setoption (options); }, Error:function(errormsg) {alert (errormsg); }    });

ASHX service returned, JavaScriptSerializer converted to JSON

 public void   ProcessRequest (HttpContext co                ntext) { try   =infoservice.getchart (Arg1, arg2); JavaScriptSerializer js  = new                  JavaScriptSerializer (); Context.                Response.ContentType  = "Text/plain" ; Context. Response.Write (JS.            Serialize (infolist));  catch   {C Ontext.                Response.ContentType  = "Text/plain" ; Context.            Response.Write ( "error" ); }        }                    

Echarts HTML parameter +JS request +ASHX Service Code mode

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.