Last active
November 9, 2016 05:05
-
-
Save asadaly111/56fde426cb5364690839315d04591779 to your computer and use it in GitHub Desktop.
Ajax in Php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$('#searhform').submit(function(event) { | |
event.preventDefault(); | |
var formData = new FormData($(this)[0]); | |
var url = $(this).attr('action'); | |
$.ajax({ | |
type: 'post', | |
url: url, | |
contentType: false, | |
processData: false, | |
data: formData, | |
}) | |
.done(function(value) { | |
console.log(value); | |
}) | |
.fail(function() { | |
console.log("error"); | |
}); | |
}); | |
<!-- one array and one single input in ajax --> | |
$("form.sendemail").submit(function ( event ) { | |
event.preventDefault(); | |
var url = $(this).attr('action'); | |
info = []; | |
info[0] = $('input[name="email[]"').val(); | |
var id = $('#summernote').code(); | |
var data_to_send = $(this).serialize(info); | |
var dataString = data_to_send + '&id=' + id; | |
$.ajax({ | |
type: "POST", | |
data: dataString, | |
url: url, | |
success: function(msg){ | |
console.log(msg); | |
} | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment