2
    $.post('/ur.l'
          , jQuery('selectors').serialize() 
                               + '&textareaname=" + escape( $("#textarea").val() )
          , function(data) { ... } 
          }
    );

    $.post('/ur.l'
          , {'foo':'bar', 'foobar','qazbar'}
          , function(data) { ... }
    );

Problems

  1. Is it possible to combine the object into {...} the jQuery serialization?

  2. jQuery doesn't seem to serialize textareas, is there a better method than the above? I've tried and see that the textarea is in the jQuery object, but the text is blank:

    jQuery('input, textarea').serialize()
    

2 Answers 2

4
  1. jQuery.param will serialize an object into a url encoded string. You can then combine them together.

  2. serialize does works with textareas. Make sure you have a valid name on the textarea, and that it is not disabled.

Sign up to request clarification or add additional context in comments.

5 Comments

yes, I think my code uses param, however I'm almost definite the textarea was not being serialized. I tested in firebug and it showed that the textarea was properly found by the selector, but that it was not being serialized. I first tried a lot of text, then I used only a few words, neither worked. I'll check more next week.
Yeah I tested it here (jsfiddle.net/vol7ron/PGtPa) and it seems to work, but it definitely wasn't working at the office... we'll see.
It still wasn't working, but I'll accept this regardless, I'll have to debug and see what's up. It may be a browser problem.
Josiah - "...and that it is not disabled" that's what bit me.
for example <textarea name="TextArea1" disabled></textarea> the disabled attributes informs the serialize function to ignore this element. Disabled html form elements are not submitted with a natural form submission.
0

You should try and give your form an id and refer to the form parameters through that. For example if you form was had an id of #form.

$("#form").submit( function () {    
    $.post(
   'ur.l',
    $(this).serialize(),
    function(data){

    });
    return false;   
  });   
});

and $(this) will be the contents of all of your form parameters. Also in case you are not doing so already, take a look at the headers.

1 Comment

I did try that initially and realized that my textarea wasn't being serialized. Though, there are many thing in the form that I did not want being sent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.