1

I am trying to load a new jquery tab with HTML from the server:

$("#tab"+username).load("/lod1/ProfileServlet",{user:"username"},function(){
            //fill in template with user's info
            console.log("it worked");
 });

servlet:

    System.out.println("USERNAME HERE");
    RequestDispatcher req = request.getRequestDispatcher("/WEB-INF/profileTemplate.html");
    req.forward(request, response);

In the browser I see the confirmation 'it worked' so it seems that the request was successful. But on the server I don't see the output "USERNAME HERE" and "#tabusername" is not populated with the html requested(which I can confirm is in the right place):

<!DOCTYPE html>

<div>
    <h1>USERS PROFILE AND THEME</h1>
</div>
Kresimir
  • 737
  • 5
  • 20
SallyRothroat
  • 585
  • 1
  • 5
  • 17

1 Answers1

3

As your servlet is listening for a GET, you can't pass the data to .load() as the second data parameter.

Use this to call the servlet with a GET:

$("#tab"+username).load("/lod1/ProfileServlet?user="+username, function() {
    //fill in template with user's info
    console.log("it worked");
});
jordiburgos
  • 5,363
  • 3
  • 45
  • 73