Skip to content

Instantly share code, notes, and snippets.

@0test
Last active November 14, 2019 12:01
Show Gist options
  • Save 0test/d01a621386ca0a581453df702f9c9bb2 to your computer and use it in GitHub Desktop.
Save 0test/d01a621386ca0a581453df702f9c9bb2 to your computer and use it in GitHub Desktop.
Мой любимый аякс - обёртка для вызова
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