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
javascript scala playframework


source to share


No one has answered this question yet

Check out similar questions:

2614
How do I change the class of an element using JavaScript?
2245
How do I refresh the page using jQuery?
1854
When should you use double or single quotes in JavaScript?
1494
Scroll to the top of the page using JavaScript?
1379
JavaScript submit request, how to submit a form
1198
Pure JavaScript jQuery $ .ready () equivalent - how to call a function when the page / DOM is ready for it
860
How do I execute a JavaScript function when I have its name as a string
651
How do I get JavaScript to work after the page has loaded?
609
How to reload a page using JavaScript
607
Playing audio with Javascript?



All Articles
Loading...
X
Show
Funny
Dev
Pics