Play Framework does not refresh the page when javascript post changes

So the problem is that I have 2 combo boxes, comboONE and comboTWO. the population of comboTWO depends on the choice of comboONE ... i.e. when comboONE is selected I want to go to the server and pass the appropriate values ​​for the comboTWO.

Everything seems to connect and even the call that returns from the Controller gets called ... but strangely doesn't refresh the page ... it's true if I post it to a completely different page.

So some code ... scala template looks like ...

@(adminAccess: Boolean, theLocationClassTimes: List[String])
<!DOCTYPE html>

:
:
    <script>
        function populateClassTimeSelect(classLocation) {
        var req = new XMLHttpRequest() ;
        req.open("post", "/locationclasstimes/" + classLocation);
        req.onload = function ( e ) {
            if ( req.status = 200 )  {
                document.reload(true);
            }
        };
        req.send();
        }
    </script>
:
// And use "theLocationClassTimes" list down here

      

The routes file has ...

GET         /contacts.html                            controllers.Application.contacts
POST        /locationclasstimes/:classLocation        controllers.Application.locationClassTimes(classLocation: String)

      

... and then the controller is like ...

 def contacts = SecureAction { request =>
    Ok(views.html.contacts(isAdminUser(request), List("andyOne", "andyTwo")))
  }

  def locationClassTimes(classLocation: String) = SecureAction  { request =>
    val validClassTimesForLocation = List("Hello1","Hello2", classLocation)
    Ok(views.html.contacts(!isAdminUser(request), validClassTimesForLocation))
  }

      

What I have to say is that the names are small here ... but basically the "locationClassTimes" function is called as expected and creates my new list. But the HTML page doesn't update with new content. And if I send it a completely different page, I can see that it does the required processing (i.e., Reading the DB for that page), but it doesn't actually do it.

So, I have two main questions: (1) Is there something obvious I am doing wrong to connect the dots here (2) Is there an easier way to connect comboONE with comboTWO in the playback platform. I want to get to the service level / DB at this point.

Thanks a lot for any pointers as I am completely new to all things webby!

+3


source to share





All Articles