Answer the question
In order to leave comments, you need to log in
Ajax requests in Drupal 7 like in WordPress, is it possible?
Trite, but yes, is it possible to build your ajax requests in drupal in the likeness of wordpress, but with a handler function in template.php? Standard tools like Drupal.ajax do not suit.
For example, in wp it is done like this:
ajax
$.ajax({
url: ajaxurl, // ссылка обрабатываемая ajax запрос ../wp-admin/admin-ajax.php
data: {
'action': 'addreview', // action - действие к которому позднее прикрутиться хук/функция обработчик
'form_data': form_data, // какие-то данные
},
type: 'post',
dataType: 'json',
success:function(json){} // результат
});
function clinic_add_rewiew_form(){
// $_POST['form_data'] Что-то обрабатывает
die();
}
add_action('wp_ajax_addreview', 'clinic_add_rewiew_form'); // регистрирует функцию обработчик
// add_action('wp_ajax_($action)', function_name());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question