var param=“{'dn':'dn','area':'area','yoursugguest':'suggest',}";
param = eval('(' + param + ')');
$.ajax({
url:"/liferayStudy-servlet/CreateTeamServlet", async:false,timeout:'900000',type:'POST', data: param,encode:'UTF-8',datatype:'jsonp',success:function(data,textStatus){
data= eval("(" + data + ")");
// parent.location.href="/livemeeting?"
// +"teamId="+data["teamId"];
//201207081712
parent.window.location.href="../../en_GB/web/"+data["title"].toString()+"/home";
},error:function(XMLHttpRequest,error){
if (error == "timeout")
alert("timeout");
if (error == "parsererror")
alert("parsererror!");
}
});
servlet端
JSONObject param = new JSONObject(); JSONObject responseJSON = new JSONObject(); int teamID = -1; try { param.put("team",request.getParameter("dn")); param.put("userId","1"); param.put("title",request.getParameter("area")); param.put("des",request.getParameter("yoursuggest")); System.out.println("area =="+ request.getParameter("area")); CreateTeamUtil.addLiferaySite(param,request); CreateTeamUtil.addTeam(param); teamID= CreateTeamUtil.getTeamID(param); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (sqlException e) { // TODO Auto-generated catch block e.printStackTrace(); } // if(teamID != -1) { try { //responseJSON.put("teamId",teamID); responseJSON.put("title",request.getParameter("area")); } catch (JSONException e) { // TODO Auto-generated catch block e.printStackTrace(); } System.out.println("----reponseJson--- " + responseJSON.toString()); response.getWriter().print(responseJSON.toString()); //返回数据原文链接:https://www.f2er.com/ajax/166110.html