I am working on a Spring MVC application in which I need to show details of a Trip object. Following is my TripModel:
@Entity
@Table(name="Trip")
public class TripModel {
    private String locationName;
    private String userName;
    @Id
    @Column(name="tripid")
    @GeneratedValue 
    private int tripId; 
    @Column(name="tripid")
    private int tripId;
    @Column(name="locationid")
    private int tripStopLocationId;
    @Column(name="datetime")
    private String tripStopDateTime;
    @Column(name="createts")
    private Date tripStopCreateTime;
    @Column(name="userid")
    private int createUserId;
    @Transient
    private List<ItemTransactionModel> itemTransactionModelList;
}
How can I get trip details using trip id, in AJAX? TripModel has a list of ItemTransactionModel objects.
Following is my ajax code:
jQuery.ajax({
        url: '<c:url value="/trip/tripdetailsbyajax" />',
        type: 'POST',
        data: "tripId="+tripId,
        cache:false,
        success:function(response){
            alert("response = " + response);
        },
        error:function(jqXhr, textStatus, errorThrown){
            alert(jqXhr);
            alert(textStatus);
            alert(errorThrown);
        }
    });
Following is my controller method:
@RequestMapping(value = "/tripdetailsbyajax", method = { RequestMethod.POST })
    public @ResponseBody TripModel getTripDetailsByAjax(int tripId) {
        TripModel tripModel = null;
        tripModel = tripService.getTripModel(tripId);
        return tripModel;
    }
How can we send TripModel object as AJAX response, and how can we access that in JavaScript? TripModel object has a list of ItemTransactionModel objects.
 
     
    