日期:2014-05-17  浏览次数:20893 次

1.怎么用 JQUERY AJAX 调用一个ACTION 这个ACTION实现一个查询功能 返回一个的是LIST 2.怎么显示在页面的一个制定的位置
1.怎么用 JQUERY AJAX 调用一个ACTION 这个ACTION实现一个查询功能 返回一个的是LIST 
2.怎么显示在页面的一个制定的位置

邮箱:
87958208@qq.com

------解决方案--------------------
jQuery.post( url, [data], [callback], [type] ) :使用POST方式来进行异步请求
参数: 
url (String) : 发送请求的URL地址. 
data (Map) : (可选) 要发送给服务器的数据,以 Key/value 的键
值对形式表示。 
callback (Function) : (可选) 载入成功时回调函数(只有当Response
的返回状态是success才是调用该方法)。
type (String) : (可选)官方的说明是:Type of data to be sent。
其实应该为客户端请求的类型(JSON,XML,等等)

比如
$.post("ACTION",function(result){
result = $.trim(result);//去空格
var List = $.parseJSON(result); //ACTION返回的应为JSON格式,转换成List
.... //List都取到了,想让它显示在哪位置更简单了,省略
})

------解决方案--------------------
这个简单。

1.画面中js。
function doQuery(){
$.ajax({url:"<%=request.getContextPath()%>/<%=PFMConstants.PFM_MODULE_FILE_UPLOAD_INFO%>/checkFileName.htm", //URL
cache:"False",
type:"get",
async: false,//同步校驗,默认为true,是异步方式 
data:{fileName:fileName},//傳入的參數
success:function(data, textStatus){//回調方法


//先移除之前的信息,再加载
$("#tab1 tbody").find('tr:not(:first)').remove();
var html = "";
$.each(data,function(index,comm){
html+='<tr class="table-odd-row">'
+'<td class="table-string-column">'+'<a href="javascript:void(0)" onclick="return deleteFile('+comm['fileNo']+');"><img src="${ctx}/images/u78.png" width="16" height="16" border="0" alt="刪除"></a>'+'</td>'
+'<td class="table-other-column">'+'<a href="<%=request.getContextPath()%>/<%=PFMConstants.PFM_MODULE_FILE_UPLOAD_INFO%>/downloadFile.htm?wh=temp&fileName='+comm['aliasFileName']+'">'+comm['fileName']+'</a>'+'</td>'
+'<td class="table-other-column">'+comm['strUploadDate']+'</td>'
+'<td class="table-other-column">'+comm['uploadUser']+'</td>'
+'<td class="table-other-column">'+comm['fileSize']+'</td>'
+'<td class="table-other-column">'+comm['comments']+'</td>'
+'</tr>';
});
$("#tab1 tbody").html(html);
}});
 

}



画面中需要写的:

<table class="tablestyle" cellspacing="0" cellpadding="0">
<tr>
<td>
<table class="table-background" id="tab1" cellpadding="2" cellspacing="1">
<thead>
<tr>
<th class="headers" scope="col">處理</th>
<th class="headers" scope="col">檔案名稱</th>
<th class="headers" scope="col">上載時間</th>
<th class="headers" scope="col">上載人</th>
<th class="headers" scope="col">檔案大小</th>
<th class="headers" scope="col">附注</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</td>
</tr>
</table>



就可以了。
HTTP Status 500,该如何处理