Question

I'm using Rails 2.3.8 and have a jQuery AJAX form using posted using:

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

If I try to post a text that has quotes in it such as

1
"2"
3

Only what is inside the quotes is received as parameter:

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

Any idea why ?

jQuery.serialize inside the browser returns note%5Bnote%5D=1%0A%222%22%0A3

Update: Here's the form

<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>
Was it helpful?

Solution

This is due to a bug in Rack which is still present in Rails 2.3.8: https://rails.lighthouseapp.com/projects/8994/tickets/4808-textarea-input-silently-truncated-in-238

The patch on the ticket fixes this until it's updated upstream.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top