allthenutsandbolts
allthenutsandbolts

Reputation: 1523

Rendering template via AJAX in Grails

I have the following code in an action

    render ( template: 'partial_list_template', model: [messageList: entries, totalFound: count, activeUILink: "all_mgs_link", termFreqs: null])

I have the following code in the gsp page

$j("#filterUpdate").click(function(event){

        var form = $j('#flags');



         new Ajax.Request('/tabulae/webForm/filter',
                {
                onSuccess:function(resp){

                               console.log(resp.responseText);
                                console.log($j('#filterResults'))
                                $j('#filterResults').remove()
                                $j('#filterResults').innerHTML(resp.responseText)
                            },
                            onError: function(resp) {
                                alert("Error:" + resp.toJSON());
                                return;
                            },
                            asynchronous:true,
                            evalScripts:true,
                            method:'GET',
                            parameters:form.serialize()

                });
      });

even though I see the html output in the console log. I don't see the html output in the element where I'm adding this content. Any ideas why ?

Upvotes: 3

Views: 4110

Answers (2)

mjs
mjs

Reputation: 22409

Do not use .remove() since then you will be removing the element and in the next step there is no element to be found. But also, there is no method called .innerHTML() ... you should be using .html()

Hope that helps

Upvotes: 4

Rafay
Rafay

Reputation: 31043

try using empty

$j('#filterResults').empty();                            
  $j('#filterResults').innerHTML(resp.responseText);

Upvotes: 2

Related Questions