1$('form').serializeArray()
2// gives
3// [ {"name":"foo","value":"1"},
4// {"name":"bar","value":"xxx"},
5// {"name":"this","value":"hi"} ]
6
7
8// or
9
10$('form').serialize() // gives : "foo=1&bar=xxx&this=hi"
1$(function(){
2 $('form').on('submit', function(e){
3 e.preventDefault();
4 $(this).serializeObject().done(function(o){
5 if(window.console) console.log(o);
6 var j = JSON.stringify(o);
7 alert(j);
8 //window.open("data:image/png;base64," + o.userfile.data);
9 });
10 });
11});
1 $(document).ready(function(){
2
3 $("#buttonSet").click(function () {
4 $("#txtBox").val("Amit");
5 $("input:radio").val(["male"]);
6 $("#buttonGet").removeAttr('disabled');
7 });
8 $("#buttonGet").click(function () {
9 $("#result").html(
10 $("#txtBox").val() + "<br/>" +
11 $("input:radio[name=rd]:checked").val()
12 );
13 });
14 });
1var fd = new FormData();
2fd.append( 'file', input.files[0] );
3
4$.ajax({
5 url: 'http://example.com/script.php',
6 data: fd,
7 processData: false,
8 contentType: false,
9 type: 'POST',
10 success: function(data){
11 alert(data);
12 }
13});
1<html>
2 <form id="myForm">
3 <input type="text" name="email" value="user@example.com">
4 </form>
5 <p id='text'></p>
6
7 <script>
8 window.setInterval(()=>{
9 var myForm = document.getElementById('myForm');
10 var text = document.getElementById('text');
11
12 text.innerText = myForm.elements['email'].value;
13 }, 1);
14 </script>
15</html>