- Data Type
JS Code:
$. Post ("getmaterial. do? Method = getmaterial ", <br/> {Name: name}, <br/> function (data) {</P> <p> });
Getmaterial. do? Method = getmaterial is the request URL, and {Name: name} is the parameter passed to the background. You can use
Request. getparameter ("name"); get, data is transmitted from the background.
Action Code:
Response. setcontenttype ("text/html; charset = GBK"); <br/> printwriter out = response. getwriter (); <br/> out. println ("test ");
In this case, data is test.
2. XML data is returned.
JS Code:
// Post sending method <br/>/* $. post ('. /getsd. do ', STR, <br/> function (XML) {<br/> alert (XML. XML); <br/> $ ("# otherinfo" ).html ("Project name:" + $ ("proname", XML ). text () + "test pair </P> <p> image:" + $ ("testaim", XML ). text (); <br/>}, "XML ");*/
Action Code:
/* Response. setheader ("charset", "UTF-8"); <br/> out. println ("<? XML version = '1. 0' encoding = 'utf-8'?> "); <Br/> out. println ("<result>"); <br/> while (RS. next () {<br/> out. println ("<testaim>"); <br/> out. println (RS. getstring ("testaim"); <br/> out. println ("</testaim>"); <br/> out. println ("<proname>"); <br/> out. println (RS. getstring ("proname"); <br/> system. out. println (RS. getstring ("proname"); <br/> out. println ("</proname>"); <br/>}< br/> out. println ("</result> ");*/
3. Return JSON data
JS Code:
$. Getjson ('. /getsd. do ', {Ylid: Ylid}, function callback (JSON) {<br/> // alert (JSON. proname); <br/> // $ ("# otherinfo" ).html ("Project name:" + JSON. proname + "test pair </P> <p> image:" + JSON. testaim); <br/> $ ("# proname "). ATTR ("value", decodeuri (JSON. proname); <br/> $ ("# testaim "). ATTR ("value", decodeuri (JSON. testaim); <br/> });
Action Code:
/** <Br/> * return data in JSON format <br/> */<br/> jsonobject JB = new jsonobject (); <br/> while (RS. next () {<br/> system. out. println (RS. getstring ("proname"); <br/> JB. put ("testaim", java.net. urlencoder. encode (RS. getstring ("testaim"), "UTF </P> <p>-8"); <br/> JB. put ("proname", java.net. urlencoder. encode (RS. getstring ("proname"), "UTF </P> <p>-8"); <br/>}< br/> out. println (JB. tostring ());