dojo中xhrGet的用法

前端之家收集整理的这篇文章主要介绍了dojo中xhrGet的用法前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

1.前台页面

function sayHello() {
var userName=dojo.byId("userName").value;
dojo.xhrGet({
url: "<%=request.getContextPath()%>/test.do?method=test",
handleAs: "text",
content: { key1:userName,key2: "value2",key3: "value3" },
load: function(responseText)
{
dojo.byId("first_name").value = responseText;
dojo.byId("t1").value = responseText;
dijit.byId("description").value = responseText;
document.getElementById("middle_initial").value=responseText;
},
error: function(response)
{
alert("Error");
}
});
}

2.后台action中:

public ActionForward test(ActionMapping mapping,ActionForm form,HttpServletRequest request,HttpServletResponse response) throws Exception { request.setCharacterEncoding("utf-8"); response.setContentType("text/html"); response.setCharacterEncoding("utf-8"); PrintWriter out = response.getWriter(); String key1=request.getParameter("key1"); out.print(key1); return null; }

猜你在找的Dojo相关文章