jQuery: Possible to use object and serialize for passing parameters?
$.post('/ur.l'
, jQuery('selectors').serialize()
+ '&textareaname=" + escape( $("#textarea").val() )
, function(data) { ... }
}
);
$.post('/ur.l'
, {'foo':'bar', 'foobar','qazbar'}
, function(data) { ... }
);
Problems
Is it possible to combine the object into
{...}
the jQuery serialization?jQuery doesn't seem to se开发者_开发百科rialize 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()
jQuery.param will serialize an object into a url encoded string. You can then combine them together.
serialize
does works with textareas. Make sure you have a valid name on the textarea, and that it is not disabled.
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.
精彩评论