I am trying to display response from the rails server in a div
.
ajax call is like this
$.get('/news/search?search=' + existingString, function(data) {
$("#results").html("");
console.log(data);
len=data.length;
$('#result').append('#{escape_javascript(render("newsdisplay") )}');
_newsdisplay.html.haml
- if @results
- @results.each do |anzen|
%li.clearfix.postMain.allnews
.wrapper
%li
.messaIcon
.icon
%img{:src => anzen.news_image.thumb.url}
.messaCon
.areaDay.clearfix
%p.messaTextCon
グループ名:
%span= anzen.news_name
search action
def search
if params[:search].present?
@results = News.search(params[:search])
end
end
routes.rb
get 'news/search', to: 'news#search', as: :newssearch
I am getting the response from the server correctly. But no change in the page.But in console the full page with rendered response is displayed. Can anyone guess the issue