Country class
City Class
Services Class
class Pages {
String name
String address
String postcode
String description
Long phone
String email
String website
static belongsTo = [country: Country, city: City, services: Services]
----------------------------------------------------------------------------------
Test 1 ) Controller;
def search = {
def city = City.findByName(“london”)
def services = Services.findByName(“petshap”)
def results= Pages.findAll("from Pages as p where p.city = ? and p.services = ?" ,[city, services])
render results as JSON
}
POST Via AJAX; url posted is: http://localhost:8080/com.api.test/Pages/search/
The above example works OK (result [{"class":"com.api.test.Pages","id":2," etc…
------------------------------------------------------------------------------------
Test 2 ) Make a change to Controller;
def search = {
def city = City.findByName(params.id)
def services = Services.findByName(“bus36”)
def results= Pages.findAll("from Pages as p where p.city = ? and p.services = ?" ,[city, services])
render results as JSON
}
POST Via AJAX; url posted is: http://localhost:8080/com.api.test/Pages/search/London
The above example works OK (result [{"class":"com.api.test.Pages","id":2," etc…
----------------------------------------------------------------------------------
Now this is what I want to do:
Test 3 ) Make a change to Controller;
def search = {
def city = City.findByName(params.id)
def services = Services.findByName(params.id)
def results= Pages.findAll("from Pages as p where p.city = ? and p.services = ?" ,[city, services])
render results as JSON
}
POST Via AJAX; url posted is: http://localhost:8080/com.api.test/Pages/search/London?Bus36
(Result [] empty
Please let me know if use of ‘?’ to separate the params value is correct? (London?Bus36) I tried ‘,’ or ‘+’ or ‘&’ and they all return [].
How would you pass the to two query params in url? So I can make the AJAX to POST that pattern