Ajax交互方法(一)

来源:互联网 发布:暗黑3数据挖掘者成就 编辑:程序博客网 时间:2024/06/10 20:29
function doQueryRecord(req,param) {var myAjax=new Ajax.Request ( //发送ajax请求url,   //action url{method:'post',parameters:param,onComplete:ajaxQueryTableEnd   //回调函数});}//查询结束function ajaxQueryTableEnd(request) {var str='';var listcount=0;try {var obj=request.responseText;   //得到返回值的方法,一般用Json传递数据} catch (oError) {alert('查询失败');}createListTableString(obj);}/** * 显示表格 * @param {} str--表格内容tr */function createListTableString(obj) {          //将返回的html放到Table对象中var tablea='<table id="data" border="1" align="center"'+' style="border: 0px solid black">'+obj+'</table>';document.getElementById('tableContainer').innerHTML=tablea;}Action返回:public class CallInReportAction extends AbstractAction{  //注意继承
AbstractAction
this.printToResponse(StringJson);



原创粉丝点击