This example shows how extjs Ajax parses common strings.
JS
Function teststringajax () {var areaname = ""; Ext. ajax. request ({method: 'post', // Request Method URL: 'teststringajax ', // URL Params: {areaname: "" + areaname + ""}, // The parameter to be passed. This parameter can be a set of parameters waitmsg: 'Data is being updated. Please wait... ', success: function (response, options) {var textdoc = response. responsetext; // note that responsetext if (textdoc! = NULL) {var Vs = textdoc. split ('prop _^ '); document. getelementbyid ("ZCL "). innerhtml = vs [0]; // display the obtained value on the document page. getelementbyid ("ZYC "). innerhtml = vs [1] ;}}, failure: function (response, options) {Ext. MSG. alert ("message prompt", "An error occurred while retrieving database data. Please try again later! ") ;}, Autoabort: false });}
Ext.onReady(testStringAjax);
JSP code
<Div id = "ZCL"> </div>
<Div id = "ZYC"> </div>
Action
Public String teststringajax () {try {string S = "Hi ^_^ hello"; response. getwriter (). print (s); response. getwriter (). flush (); response. getwriter (). close ();} catch (exception e) {e. printstacktrace ();} return NULL ;}