Wednesday, 25 July 2012

Filling Html Data From Sever Into Html Element Using Ajax And Spring MVC 3.0

//placed this code in controller in controller
@RequestMapping(value = "/show.htm")
protected ModelAndView showStudent(@RequestParam("id") Long studentId,HttpServletRequest request,HttpServletResponse response) throws Exception {
         System.out.println("inside ajax");
       //getting Student Object From Database using StudentDao
        Student student = studentDao.getStudent(studentId);
      //createing ModelAndView Object
      ModelAndView modelAndView = new ModelAndView("show");
// putting student Into the model for used into the show page
return modelAndView;

//put this code in jsp within script tag
function viewStudent(studentId)
            //create ajax object using jquery or prototype or mootools or javascript
        //here we use jquery
         data:({id : studentId}),     //parameter passed ti the controller
        success:function(data){   // callback function after the request is completed

            // 'studentViewDiv' is the target div
            // where we want to display our response
You can buy Xiomi Note from Flipkart ::: Click Here

No comments:

Post a Comment