porno porno rokettube
Results 1 to 2 of 2

Thread: How to receive model via ajax

  1. #1
    Junior Member
    Join Date
    Aug 2014
    Posts
    1

    How to receive model via ajax

    All,

    I have two questions one major one minor. My minor question is why does this simple grails app not work?

    Code:
    Person Domain
    
    package ajax
    
    class Person {
        String firstname
        String lastname
        int age
    
    
        static constraints = {
        }
    }
    HomeController
    
    package ajax
    class HomeController {
    
        def index() {
        render (view: "index")
        }
        def greet()
        {
            render "hi"
        }
        def getPersons()
        {
            def persons = Person.getAll()
            render(model: [persons:persons])
        }
    }
    index.gsp
    
    <%@ page contentType="text/html;charset=UTF-8" %>
    <html>
    <head>
        <title></title>
        <g:javascript plugin="jquery" />
    </head>
    
    <body>
    <div id="greeting"></div><br>
    <button onclick='<g:remoteFunction action="greet" update="greeting"/>'>Click on me!</button>
    </body>
    </html>
    And finally my major question is, in index.gsp if I wanted to change the button action to getPersons, then how would I get the data via ajax or jquery e.g. g:remoteFunction .And if I did get the data how would I format the data in #greeting so I get the firstname and lastname.

  2. #2
    Junior Member
    Join Date
    Aug 2010
    Posts
    4
    I know its a little late but if you still want help then let me know .. what problem you having with your app ?

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Forum Design by Tucanoo Solutions Ltd Grails Development Specialists.