|
Hi there,
I have the following piece of code in my gsp page $j(document).ready(function() { $j("#searchButton").click(function(event){ var form = $j('#federatedSearchForm'); $j.ajax({ type:'POST', url:'/tabulae/federatedSearch/ajaxGetSearchResults', data:form.serialize(), cache:false, error:function(request,status,error) { alert(status) }, success:function(data,status,xhr) { alert(data); }, complete:function(xhr,status) { } }); }); }); I have the folllowing code in my controller def ajaxGetSearchResults = { log.debug "params:" + params def returnResults = federatedSearchService.search(params) render returnResults as JSON } when I log the return results. I get the data also when I call the action directly in my browser with the necessary params, I get the result back. Its only when I don't see any data in my success function of my jQuery call. I'm using jQuery.1.7.1 in my application. Thanks - Harjit --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
do you see the return in firebug or the like?
On Tue, Feb 21, 2012 at 2:38 PM, [hidden email] <[hidden email]> wrote: > Hi there, > > I have the following piece of code in my gsp page > > $j(document).ready(function() { > $j("#searchButton").click(function(event){ > > var form = $j('#federatedSearchForm'); > $j.ajax({ > type:'POST', > url:'/tabulae/federatedSearch/ajaxGetSearchResults', > data:form.serialize(), > cache:false, > error:function(request,status,error) { > alert(status) > }, > success:function(data,status,xhr) { > alert(data); > }, > complete:function(xhr,status) { > } > > }); > > }); > }); > > > I have the folllowing code in my controller > > > def ajaxGetSearchResults = { > > log.debug "params:" + params > > def returnResults = federatedSearchService.search(params) > > > render returnResults as JSON > > } > > when I log the return results. I get the data also when I call the action directly in my browser with the necessary params, I get the result back. Its only when I don't see any data in my success function of my jQuery call. I'm using jQuery.1.7.1 in my application. > > Thanks > > > - Harjit > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email |
|
In reply to this post by harjit@teslagovernment.com
1. Test
jquery ajax function work or not
Try to make some call to public service, like google 2. Check GET to grails work or not. Have you set this method to accept GET only? On Tue, Feb 21, 2012 at 4:38 PM, [hidden email] <[hidden email]> wrote: Hi there, |
|
Install firebug and take a look at console/net tab
On Tue, Feb 21, 2012 at 2:58 PM, Gavin Yue <[hidden email]> wrote: 1. Test jquery ajax function work or not Regards Gaurav Chauhan Contact No : +91-95607-66664 Skype : chauhan.gaurav Website : JellyFish Technologies
|
|
Here is what I figured out.
The success method is called before even the results are returned. How is that possible? I have a service call in my controller which actually queries the database and return the result. - Harjit On Feb 21, 2012, at 6:32 PM, Gaurav Chauhan wrote: Install firebug and take a look at console/net tab |
|
Found the issue.
I just had to call preventDefault() before the ajax call, that fixed it Thanks for the responses. - Harjit
On Feb 22, 2012, at 9:50 AM, [hidden email] wrote:
|
| Powered by Nabble | Edit this page |
