Ajax+JSON 回调函数?SSH添加数据~! 在线求解

问题描述

//Service层InsertEntity是自定义的实体,InsList数据库实体orm里的实体publicvoidinsert(InsertEntityinsertEntity){InsListinsList=newInsList();insList.setInsName(insertEntity.getInsName());insList.setInsMade(insertEntity.getInsMade());insList.setInsSeller(insertEntity.getInsSeller());insList.setInsSellPrice(insertEntity.getInsSellPrice());insList.setInsBuyPrice(insertEntity.getInsBuyPrice());this.alldao.getInsListDao().attachDirty(insList);}

publicclassinsertActionextendsBaseAction{privateStringJSONInsert;//页面json传过来的参数publicStringgetJSONInsert(){returnJSONInsert;}publicvoidsetJSONInsert(StringjSONInsert){JSONInsert=jSONInsert;}privateInsertEntityinsertList=newInsertEntity();publicInsertEntitygetInsList(){returninsertList;}publicvoidsetInsList(InsertEntityinsertList){this.insertList=insertList;}publicStringexecute(){try{JSONObjectjson=JSONObject.fromObject(JSONInsert);this.getAllService().getInsertService().insert(insertList);//重点问题就在这里,报错null值求高手解释ServletActionContext.getResponse().setContentType("text/html");ServletActionContext.getResponse().setCharacterEncoding("utf-8");ServletActionContext.getResponse().getWriter().printf(json.toString());ServletActionContext.getResponse().getWriter().flush();ServletActionContext.getResponse().getWriter().close();}catch(IOExceptione){//TODOAuto-generatedcatchblocke.printStackTrace();}returnnull;}

//页面ajax提交xml都配置好了functioninsertAction(){varinsName=$("#insName").val();varinsMade=$("#insMade").val();varinsSeller=$("#insSeller").val();varinsBuyPrice=$("#insBuyPrice").val();varinsSellPrice=$("#insSellPrice").val();varJSONInsert=JSON.stringify(newinsertEntity(insName,insMade,insSeller,insBuyPrice,insSellPrice));alert(JSONInsert);$.get("insertAction.action?t="+newDate(),"&JSONInsert="+JSONInsert,function(data){alert(data);});}functioninsertEntity(insName,insMade,insSeller,insBuyPrice,insSellPrice){this.insName=insName;this.insMade=insMade;this.insSeller=insSeller;this.insBuyPrice=insBuyPrice;this.insSellPrice=insSellPrice;}

时间: 2024-08-02 19:50:01

Ajax+JSON 回调函数?SSH添加数据~! 在线求解的相关文章

json-使用jQuery ajax,回调函数必须在有一个alert()的前面才能执行?

问题描述 使用jQuery ajax,回调函数必须在有一个alert()的前面才能执行? 请问下 $(document).ready(function() { $("#confirm").submit(function(){ var $form = $(this); $.post($form.attr("action"),$form.serialize(),function(data){ alert("5555"); if (data.code

jQuery Ajax Post 回调函数不执行问题的解决方法_jquery

今天在写一个检查用户名的功能时,使用的是jQuery.post( url, [data], [callback], [type] )这个函数,但是发现其中的回调函数不能执行. 先来看看我的代码: 前台代码: <script type="text/javascript"> function checkUser() { var user = $('#<%=txtUser.ClientID %>').val(); $.post('checkUser.ashx', {

php懒人函数 自动添加数据

复制代码 代码如下: /* *@自动添加数据函数 *@$table 表名 *@$arr 字段库 array("title",array("content",int)) *@ array(字段,类型) *@ 类型说明 html--允许html unhtml-不允许html int --int类型 float -- float 类型 */ //自动插入数据函数 function autoInsert($table,$arr=array(),$method='post')

php懒人函数 自动添加数据_php技巧

复制代码 代码如下: /* *@自动添加数据函数 *@$table 表名 *@$arr 字段库 array("title",array("content",int)) *@ array(字段,类型) *@ 类型说明 html--允许html unhtml-不允许html int --int类型 float -- float 类型 */ //自动插入数据函数 function autoInsert($table,$arr=array(),$method='post')

ajax异步回调函数中给外部变量赋值的问题探讨_AJAX相关

复制代码 代码如下: <!doctype html> <head> <meta charset="utf-8"> </head> <body> <script src="http://localhost/UIBMSPHPProj/public/js/jquery-1.8.2.min.js"></script> <script> $(function(){ var str

ajax异步回调函数中给外部变量赋值的问题探讨

复制代码 代码如下: <!doctype html> <head> <meta charset="utf-8"> </head> <body> <script src="http://localhost/UIBMSPHPProj/public/js/jquery-1.8.2.min.js"></script> <script> $(function(){ var str

Windows Service中调用dll 回调函数不执行(在线等)

问题描述 WindowsService中调用dll回调函数不执行,非回调函数正常:部分代码publicdelegatevoidGESCALLBACK(stringExtNum,intstatus);[DllImport("ExtStatusShow.dll")]publicstaticexternintRegGetExtStatusCBEvent(GESCALLBACKFunc);...publicvoid_UpdateExtStatus(stringExtNum,intstatus)

ajax异步回调函数无法调用

问题描述 ajax.js代码: url正确,已经进入到对应的aciton并执行有结果,但是 xmlHttp.onreadyStatechange=function()  这句一直未执行,我在函数里写了alert并未跳出,请大神看看娜丽有问题~~   action的代码:  public ActionForward execute(ActionMapping mapping, ActionForm form,HttpServletRequest request, HttpServletRespon

Ajax+JSON传参的问题?在线等

问题描述 varinsId=$("#insId").val();varinsName=$("#insName").val();varinsMade=$("#insMade").val();varinsSeller=$("#insSeller").val();varinsBuyPrice=$("#insBuyPrice").val();varinsSellPrice=$("#insSellPrice