jquery serialize
var datastring = $("#contactForm").serialize();
$.ajax({
type: "POST",
url: "your url.php",
data: datastring,
dataType: "json",
success: function(data) {
//var obj = jQuery.parseJSON(data); if the dataType is not specified as json uncomment this
// do what ever you want with the server response
},
error: function() {
alert('error handling here');
}
});$.fn.serializeObject = function()
{
var o = {};
var a = this.serializeArray();
$.each(a, function() {
if (o[this.name]) {
if (!o[this.name].push) {
o[this.name] = [o[this.name]];
}
o[this.name].push(this.value || '');
} else {
o[this.name] = this.value || '';
}
});
return o;
};$(function(){
$('form').on('submit', function(e){
e.preventDefault();
$(this).serializeObject().done(function(o){
if(window.console) console.log(o);
var j = JSON.stringify(o);
alert(j);
//window.open("data:image/png;base64," + o.userfile.data);
});
});
});
Also in JavaScript:
- string addition js
- how to give a person a role by id in discord.js
- js remove element from array
- javascript boolean regex match
- click on button submitting the form in angular
- google auth.onstatechange
- what is full form of jsx
- check server command discord.js
- javascript keywords
- change abclground onload jquery
- deep clone javascript object
- number to string javascript
- auto increment string in javascript
- nohup run nodejs
- js create md5 hash
- aws amplify angular example
- flag svg javascript
- how to display first value of an array in jquery
- create react app and tailwind
- webpack react proxy not working
- find method javascript
- javascript closure function example
- ways to show image in react native
- Getting the differences between two objects javascript lib