Jquery Error - While calling struts action

2019-06-14 01:33发布

问题:

I'm calling struts action from jquery like below code.

jQuery( "#dialog-form" ).dialog({ 
    autoOpen: false,
    height: 300,
    width: 350,
    modal: true,
    buttons : {
        "Search" : function() {
            jQuery.ajax({
                type : 'POST',
                url : ' <s:submit action="part" method="find" /> '
             })
        }
    }
});

Is there any way to call struts action from jquery ?

回答1:

Use

jQuery("#dialog-form").dialog({ 
  autoOpen: false,
  height: 300,
  width: 350,
  modal: true,
  buttons : {
    "Search" : function() {
      jQuery.ajax({type : 'POST',
        url : '<s:url action="part" method="find"/>'
      }); 
    } 
  }
});

submit tag will not render the url, use url tag instead.