得到一个未终止的字符串文字错误..我可以让它通过,但无法弄清楚为什么

时间:2010-07-14 14:48:30

标签: javascript jquery ruby-on-rails ajax json

我在Firebug中收到一个未终止的字符串文字错误:

Unterminated string literal
$(".search_info").html("<div id=\'sear...arm_bg.png?1279054090\" style=\"displ\n

通过点击切换'最近'

的排序方式呈现此错误

我已将其缩小为'about_us'文字。通过删除文本的某些部分,我可以让它工作。但这不是因为某些词或字符。这就是如何在搜索结果中解析最终结果(我猜测它们的对齐方式)。

变得更加棘手。我无法在本地计算机上重现错误。它只是服务器上的错误。

Rails致电:

%li
  = image_tag('sortIcon-recent.png')
  = search_sort 'Most Recent', 'published_at', 'desc'

搜索排序助手

def search_sort(name, sort_by, order = 'asc')
if params[:order_by] && params[:order_by] == sort_by
  link_to(name, url_for(:overwrite_params => { :order_by => sort_by, :direction => order, :page => nil }), :class => 'selected live')
  else
  link_to(name, url_for(:overwrite_params => { :order_by => sort_by, :direction => order, :page => nil }), :class => 'live')
  end
end

Javascript调用:

== $("#search_sort").html("#{ escape_javascript(render :partial => 'search_sort') }");

补充说明: 1.该文本放在CKeditor中。 2.使用Ruby的truncate命令解析它(它具有通过在其中添加隐藏字符来销毁WYSIWYG文本的历史记录)

就答案而言,有没有人知道我如何进一步调试这个,或者从这里做什么?

这是完整提取的GET请求(我已多次阅读这些请求,但找不到未终止的字符串文字):

$(".search_info").html("<div id=\'searchWindow\'>\n<div id=\'searchContent\'>\n<div class=\'search_result\'>\n<img alt=\"Farm_bg\" class=\"search_image_banner\" height=\"204\" src=\"/system/search_images/993/cropped/farm_bg.png?1279054090\" style=\"display: none;\" width=\"285\" />\n<div class=\'grid_8 alpha\'>\n<div class=\'left\'>\n<img alt=\"Farm_bg\" src=\"/system/search_images/993/thumb/farm_bg.png?1279054090\" />\n<\/div>\n<div class=\'grid_3 omega\'>\n<h1><a href=\"/organizations/coviellobrothers\">Coviello Brothers <\/a><\/h1>\n<div class=\'clear\'><\/div>\n<h3>Madison<\/h3>\n<div class=\'clear\'><\/div>\n<div class=\'class7\'>\nJust This And Much More\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'grid_4 omega alpha\'>\n<div class=\'left\' style=\'margin-right: 12px; width: 40px\'>\n&nbsp;\n<\/div>\n<div class=\'left\' style=\'margin-right: 12px; width: 40px\'>\n<a href=\"/organizations/993/deals/view\"><img alt=\"Hq-card-icon\" src=\"/images/hq-card-icon.png?1279112378\" /><\/a>\n<\/div>\n<div class=\'left\' style=\'margin-right: 12px; width: 40px\'>\n&nbsp;\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'grid_4 omega alpha\' style=\'height: 25px; overflow: hidden;\'>\n<p>\n    Coviello Brothers serving Landscape Customers For Over 30 Years\n   \n  \n  located In Madison, C...<\/p>\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<div class=\'clear\'><\/div>\n<\/div>\n<\/div>\n<div class=\'clear\'><\/div>\n<br />\n<div class=\'align_right\'><\/div>\n<div class=\'clear\'><\/div>\n");
$("#search_sort").html("<div class=\'class7\'>\nSort By:\n<\/div>\n<div class=\'clear\'><\/div>\n<div id=\'sort\' style=\"background: url(\'/images/sort-box-large.png\') no-repeat; padding: 15px 10px\">\n<ul>\n<li>\n<img alt=\"Sorticon-24hr\" src=\"/images/sortIcon-24hr.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=contactable&amp;q=coviello+brothers\" class=\"live\">24hr Contact<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-card\" src=\"/images/sortIcon-card.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=best_deal_score&amp;q=coviello+brothers\" class=\"live\">HQcard Promotion<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-video\" src=\"/images/sortIcon-video.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=number_of_videos&amp;q=coviello+brothers\" class=\"live\">Video<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-trust\" src=\"/images/sortIcon-trust.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=rating&amp;q=coviello+brothers\" class=\"live\">Trust Ranking<\/a>\n<\/li>\n<li>\n<img alt=\"Sorticon-recent\" src=\"/images/sortIcon-recent.png?1279112378\" />\n<a href=\"/organizations/search?_=1279118265076&amp;commit=go&amp;direction=desc&amp;order_by=published_at&amp;q=coviello+brothers\" class=\"selected live\">Most Recent<\/a>\n<\/li>\n<li>\n<\/li>\n<\/ul>\n<\/div>\n<div class=\'clear\'><\/div>\n");
$("#search_pagination").html("");
$("#search_total h6").html("1 Result Returned!");
$("#middle_search_banner").html("<img alt=\"Farm_bg\" height=\"204\" id=\"search_image_banner\" src=\"/system/search_images/993/cropped/farm_bg.png?1279054090\" width=\"285\" />\n");

这是打破它的文本(这被粘贴为CKeditor中的纯文本)。此外,作为提醒,我尝试删除“:”和其他字符,但它仍然产生相同的错误:

  

Coviello Brothers为景观客户服务超过30年。 Coviello Brothers位于麦迪逊,是一家提供全方位服务的设计和建筑景观业务,自1973年以来一直由家族拥有和经营。我们拥有一名持牌景观设计师,协助您设计理念。我们获得灌溉安装,农药应用和石墙建筑认证。我们提供全方位的园林绿化服务,包括:

1 个答案:

答案 0 :(得分:5)

你有一个未终止的字符串文字:

$(".search_info").html("<div id=\'sear...arm_bg.png?1279054090\" style=\"displ\n

ID将以'打开,并以"

结束