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.

On Aug 31, 6:54 pm, Kreas [email protected] 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

You have a good point on the group. :slight_smile:

On Aug 31, 1:20 pm, Frederick C. [email protected]