i using play 2.0 framework. trying update division in template page using jquery every 500ms, doesn't work. i've looked here : http://www.objectify.be/wordpress/?p=428 . pretty sure followed accurately instructions.
here tricky part of template :
<body onload="testfin()"> <div id="date_fermeture"></div> <script src="@routes.assets.at("/javascripts/jquery-1.10.2.min.js")"></script> <script> function termine(){ $('#date_fermeture').load('/eleve/infoheure/@serie.id'); } function testfin(){ setinterval("termine();",500); } </script> </body>
this java code :
public static result infoheure(long serie_id){ serie serie = serie.find.ref(serie_id); return ok(infoheure.render(serie.date_fermeture)); }
this route :
post /eleve/infoheure/:serie_id controllers.application.infoheure(serie_id: long)
and template infoheure.scala.html :
@(date_fermeture : date){ <div id="date_fermeture"> @if(date_fermeture!=null){ @date_fermeture.gettime() }else{ not finished. date not yet determined. } </div> }
i pretty sure "testfin" function works , call "termine" function every 500ms. "serie" class contains various things , among them date want access. code compiles without problem, page doesn't display date should.
the browser console firefox doesn't give error.
thank help.
your route defined post
method , jquery load()
performing get
request default (if don't provide post data second parameter).
you can try call directly /eleve/infoheure/...
url in browser, perform get
request , 404 error because play can't find matching route.
you have 2 solutions: change route use get
instead of post
or modify javascript call make jquery perform post
.
in case, assuming infoheure()
action doesn't modification on data, it's better change route use get
method.
Comments
Post a Comment