Last active
November 14, 2019 12:01
-
-
Save 0test/d01a621386ca0a581453df702f9c9bb2 to your computer and use it in GitHub Desktop.
Мой любимый аякс - обёртка для вызова
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
var ajax = { | |
post: function(form_wrapper_id,form_id,query_key,success_callback){ | |
//обёртка формы, айди формы, ключ запроса, код на успех | |
$.ajax({ | |
type: 'post', | |
url: '/ajax.php?q=' + query_key, | |
data: $(form_id).serialize(), | |
success:success_callback | |
}); | |
} | |
}; | |
$(document).ready(function(){ | |
$(document).on('submit', '#order_form',function(e){ | |
var is_send = false; | |
ajax.post( | |
'#order_form_wrapper', | |
'#order_form', | |
'order_form', | |
function(data){ | |
$('#order_form_wrapper').html(data); | |
} | |
); | |
e.preventDefault(); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment