Kreas
2009-Aug-31 17:54 UTC
Sinatra: jquery displays ruby code when calling for an update. a little help please.
Hey all, So I''m running into an issue with jquery when making an ajax call to retrieve a string. It comes back displaying the entire chunk of code rather than rendering it in my erb file... I''m confused. Here''s the actual code hopefully someone can help before I pull my hair out. ----results.js--- $(function() { $(".search_box").live("keyup", function() { $.getScript("/javascripts/index.js.erb"); return false; }); }); --- index.js.erb --- $("#jresults").html(''<%= escape_javascript(erb(:results, :layout => false)) %>''); This works for the most part but the <%= escape_javascript(erb (:results, :layout => false)) %> actually displays in my view when I call for the update. Looking at the source it looks like the original data is there also. Has anyone ran into this before? I''m sure it''s a big red truck but right I can''t figure it out for the life of me. OH and before I forget I''m using Sinatra for this app.
Frederick Cheung
2009-Aug-31 18:20 UTC
Re: Sinatra: jquery displays ruby code when calling for an update. a little help please.
On Aug 31, 6:54 pm, Kreas <mavroasp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hey all, > > So I''m running into an issue with jquery when making an ajax call to > retrieve a string. It comes back displaying the entire chunk of code > rather than rendering it in my erb file... I''m confused. >> Here''s the actual code hopefully someone can help before I pull my > hair out.You omitted the most relevant of code: the ruby code processing the request. Given that rails is not involved at all, the sinatra google group may be more relevant. Fred>
Kreas
2009-Sep-01 21:20 UTC
Re: Sinatra: jquery displays ruby code when calling for an update. a little help please.
You have a good point on the group. :) On Aug 31, 1:20 pm, Frederick Cheung <frederick.che...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Aug 31, 6:54 pm, Kreas <mavroasp...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > Hey all, > > > So I''m running into an issue withjquerywhen making an ajax call to > > retrieve a string. It comes back displaying the entire chunk of code > > rather than rendering it in my erb file... I''m confused. > > > Here''s the actual code hopefully someone can help before I pull my > > hair out. > > You omitted the most relevant of code: the ruby code processing the > request. Given that rails is not involved at all, thesinatragoogle > group may be more relevant. > > Fred > >