How to call Struts2 Action method in ajax?

前端 未结 2 1315
滥情空心
滥情空心 2021-02-06 18:55

How to call Struts2 Action method in ajax.Still now i worked to call servlet.is there any possibilities?if so please do share.

2条回答
  •  忘了有多久
    2021-02-06 19:35

    Update the struts.xml as

    
    
    
        
    
    
        
    
    

    jQuery code:

    $.ajax({
        url: "AJAXAction",
        type: "POST",
        data: {data: $('#txtbox').val()},
        dataType: "json",
        error: function(XMLHttpRequest, textStatus, errorThrown){
            alert('Error ' + textStatus);
            alert(errorThrown);
            alert(XMLHttpRequest.responseText);
        },
        success: function(data){         
            alert('SUCCESS');
    
           }
    });
    

提交回复
热议问题