This is the controller.
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
@RequestMapping("/getDropDownAjax")
public void fetchData(HttpServletRequest req,HttpServletResponse resp){
System.out.println("retrieving data through ajax");
String retrievedData=service.getData();
try {
resp.getWriter().write(retrievedData);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
This controller retrieves information from the service layer and it returns: [pg,ug]
This section deals with AJAX requests
function callAjax(){
$.ajax({
type:"GET",
url:"fetchData.htm",
success:function(data)
{
alert("success");
console.log(data);
},
error:function(){
alert("failed");
},
});
}
Now, I need to have pg and ug separately in order to add them to a select box. Thank you