I not able to display the json data on jsp. When i checked for console logs in browser I am able to see the json content in console. Can anyone help me with ajax code to display the data?
Web.xml content
<struts>
<constant name="struts.devMode" value="true" />
<package name="default" extends="json-default" namespace="/">
<action name="getCronDetails" class="myaction">
<result name="SUCCESS">/schedule.jsp</result>
</action>
</package>
</struts>
Action class content:
List<emp> myList=new ArrayList<emp>() ;
//setter getter method for myList
public String getCronDetails (){
myList = fetchData() ;
return "SUCCESS";
}
I want to display myList in table format which is of type emp.
Can any one help me with ajax code?
I suggest using jQuery for the ajax calls. In the html you need an element to trigger to call, as an example I am using a button.
The button should trigger the js function that calls the action. In the example I have added callbacks for disabeling the button and showing a spinner (I left them commented, as the spinner is not there).
You get the ajax response in the
responsevariable. After you get the response you can update the DOM with it's contents.