【问题标题】:Rails parses jQuery quotes wrongRails 解析 jQuery 引号错误
【发布时间】:2010-08-06 15:18:58
【问题描述】:

我正在使用 Rails 2.3.8 并且有一个使用发布的 jQuery AJAX 表单:

jQuery.fn.submitWithAjax = function() {
  this.submit(function() {
    jQuery.post(this.action, $j(this).serialize(), null, "script");
    return false;
  });
  return this;
};

如果我尝试发布包含引号的文本,例如

1
"2"
3

仅将引号内的内容作为参数接收:

Parameters: {"contact_id"=>"1", "action"=>"create", "note"=>{"note"=>"2"}, "controller"=>"notes"}

知道为什么吗?

浏览器内的jQuery.serialize返回note%5Bnote%5D=1%0A%222%22%0A3

更新:这是表格

<form action="/contacts/1/notes" class="note_form" id="note_create_form" method="post">
<p><textarea class="autogrow" cols="40" id="note_note" name="note[note]" rows="20"></textarea></p>
<p><input class="submitbut" name="commit" type="submit" value="Add this Note" /> </p>
</form>

【问题讨论】:

  • 你能把你的问题字段的 html 贴出来吗?
  • 我已经用代码更新了问题。它由 Rails 表单助手生成。

标签: jquery ruby-on-rails ajax rack


【解决方案1】:

这是由于 Rails 2.3.8 中仍然存在的 Rack 中的一个错误: https://rails.lighthouseapp.com/projects/8994/tickets/4808-textarea-input-silently-truncated-in-238

票证上的补丁修复了这个问题,直到它在上游更新。

【讨论】:

    猜你喜欢
    • 2012-02-15
    • 2014-02-03
    • 2013-02-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多