Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function ajax_send(form, php, message){
- $(function(){
- $(form).on('submit', function(e){
- e.preventDefault();
- var $that = $(this),
- formData = new FormData($that.get(0));
- $.ajax({
- url: php,
- type: 'post',
- contentType: false, // убираем форматирование данных по умолчанию
- processData: false, // убираем преобразование строк по умолчанию
- dataType: "html",
- data: formData,
- success: function(respond){
- $(message).text(respond);
- },
- error: function(){
- alert('Произошла ошибка');
- }
- });
- });
- });
- }
- ajax_send(АйДи формы, Путь/к/пхп, АйДи блока с выводом)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement