struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From john lee <>
Subject struts2 json return to front
Date Wed, 29 Oct 2014 00:50:13 GMT
  After click the button,     the value of partid is passed to action class, and see the
output '123' from the console.    the assigned value of dummymesg is displayed on the console
as well.
 but the dummymesg never return to front javascript.    looks like success or error function
call never be called, 
please advise
thanks in advance

<script type="text/javascript">$(function() {
           type: "POST",
           url: "cart-del!del.action",
           data: {'partid':'123'},
           success: function(json){
                    console.log("return success");
                    var obj = $.parseJSON(json);
                    alert("dummey mesg="+obj.dummymesg);
                    return false;
            error: function(json){
                 console.log("return error = "+json);
                 alert("json=" + json);
                 return false;
    });</script><button id="deleteButton">delete</button>

struts.xml<package name="default" extends="json-default">     ...     <action
name="cart-del" class="CartAction" method="del">
                    <result name="json-data" type="json"></result>
  public class CartAction extends ActionSupport {
     private String partid;
     public void setPartid(String partid) { this.partid=partid.trim(); }
     public String getPartid() { return partid; }
     public void setDummymesg(String dummymesg) { this.dummymesg=dummymesg; }
     public String getDummymesg() { return dummymesg; }          
          public String del() throws Exception {              dummymesg="struts
function reached";
              System.out.println("cart-del, partid="+partid+"\n");
              System.out.println("cart-del, dummymesg="+dummymesg+"\n");
              return "json-data";
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message