欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Jquery通過Ajax訪問XML數(shù)據(jù)的小例子

 更新時間:2013年11月18日 15:38:11   作者:  
這篇文章主要介紹了Jquery通過Ajax訪問XML數(shù)據(jù),有需要的朋友可以參考一下

頁面js代碼

復(fù)制代碼 代碼如下:

$.ajax({

url : '...',
type : 'POST',
dataType : 'xml',
error : function(xml) {
alert("Error loading XML document" + xml);
},
success : function(xml) {
$(xml).find("X").each(function(i) {
alert($(this).attr("Xattr"));
});
}
});


后臺輸出代碼
復(fù)制代碼 代碼如下:

public ActionForward execute(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {

response.setContentType("text/xml; charset=utf-8");
response.setCharacterEncoding("utf-8");

PrintWriter pw = response.getWriter();
Document doc = new Document();//獲取XML文件
doc.write(pw);
return null;
}

相關(guān)文章

最新評論