prime
prime

Reputation: 15574

How to use Jquery load() in Play Framework?

I tried to load an html page to a div when button click event happens.

function loadPage(page){ 
    if (page == "publications"){ 
        $( "#container" ).load("publications.scala.html");
        //$( "#container" ).load("app/views/publications.scala.html"); // also not work
        //$( "#container" ).load("../app/views/publications.scala.html"); // also not work
    } 
}

the publications.scala.htmlis in my app/views folder

So when I tried it will say at the console 404 (Not Found) for the file.

How can I make this work. Is there any specific way to do this in Play Framework.?

Upvotes: 0

Views: 464

Answers (1)

Sivakumar
Sivakumar

Reputation: 1751

Try this,

Routes

GET     /show                          controllers.Application.show()

Controller

public static Result show(){
        return ok(views.html.publications.render());
    }

Script

$( "#container" ).load("/show");

Upvotes: 1

Related Questions