Vote count:
0
I'm seeing some weird inconsistencies when submitting a form, and submitting a form over ajax with .serialize(). Here's a minimal example:
<html>
<body>
<form action="somewhere">
<select name="thing">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
<option value="mercedes">Mercedes</option>
<option value="subaru" selected="selected">Subaru</option>
</select>
<input type="text" name="name" value="val">
<button type="submit" name="thing" value="save" >Click me</button>
</form>
<script src="http://ift.tt/1loEVus"></script>
<script>
var $ = jQuery;
$('form').on('submit', function(evt) {
//evt.preventDefault();
console.log($('form').serialize());
console.log($('form').clone().serialize());
});
</script>
</body>
</html>
When you first go to the page, change the selectbox and text, you'll see in the network console (browser submit), and logging console (jQuery serialized) that the text entered is the same in both methods, but the jQuery result is missing the thing=save.
Furthermore, the serialize() is giving completely different results for the select-box, when it clone()'s the element - you can see in the console:
"thing=mercedes&name=edited" jqform.htm:18
"thing=subaru&name=edited" jqform.htm:19
Are these a common type of bug in jQuery? Does jQuery need some forms plugin to realize an exact clone of a form should be created with the same form values?
asked 25 secs ago
Aucun commentaire:
Enregistrer un commentaire