代码之家  ›  专栏  ›  技术社区  ›  Mihai A

Rails错误地解析jQuery引号

  •  0
  • Mihai A  · 技术社区  · 14 年前

    我使用的是Rails 2.3.8,有一个jQueryAjax表单,使用:

    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"}
    

    知道为什么吗?

    更新:这是表格

    <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>
    
    1 回复  |  直到 14 年前
        1
  •  0
  •   Mihai A    14 年前

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

    票证上的修补程序将修复此问题,直到更新到上游。