그래서 누군가가 새로운 배송 옵션을 선택할 때마다 Ubercart Checkout 페이지에서 새 창을 업데이트하려고합니다. 지금까지는 새로운 배송 옵션을 선택한 후 페이지를 새로 고침 할 때마다이 문제가 발생하도록했습니다. 다음 단계는 AJAX를 통해 작동하도록하는 것입니다.Drupal 7 AJAX via hook_menu
제 문제는 ajax 명령이 AJAX 콜백에서 실행되지 않는다는 것입니다. div가 업데이트되지 않습니다. 지금은 간단한 텍스트 만 있습니다. 나중에, 나는 필요한 실제 양식 정보를 추가 할 것이고, 이것은 다른 모든 문제 일 것이다. 그러나, 나는이 테스트 케이스를 작동시킬 수조차 없다.
저는 Drupal 용 Ubercart FedEx Module의 새로운 기능을 연구 중입니다. 나는 이것을 쓸데없이 노력하고있다. 나는 여러 가지 일을 시도했지만 아무 일도하지 않았습니다.
매우 명확해야 ... 아약스 호출이 발사되었음을 알고 있습니다. 나는 ajax $ .get 호출에 성공을 첨부하고 콘솔 출력을 얻으며 drupal 변수가 설정된다. 단지 div 교체 코드가 작동하지 않습니다. 이 퍼즐 작품의 다른 모든 조각.
저는 아약스 전화를 받고 자바 스크립트로 돌아갑니다. JS에서 ajax 호출에 성공 함수를 첨부하고 콘솔 출력을 성공으로 가져올 수도 있습니다. 자바 스크립트는 문제가되지 않습니다.
// Implements hook_menu()
function uc_fedex_menu() {
$items = array();
$items['uc_fedex_jquery_callback/%'] = array(
'title' => 'My Custom Callback',
'description' => 'Listing of blogs.',
'page callback' => 'uc_fedex_calendar_jquery_callback',
'page arguments' => array(1),
'access arguments' => array('access content'),
'access callback' => TRUE,
'type' => MENU_CALLBACK,
);
return $items;
}
// AJAX callback: Updates calendar
// THIS IS WHERE THE ERROR IS... the variable is set
// But the div content is never replaced.
function uc_fedex_calendar_jquery_callback($argument) {
variable_set('uc_fedex_shipment_type',$argument);
$commands[] = ajax_command_replace('#fromdate', "works");
return array('#type' => 'ajax', '#commands' => $commands);
}
// Actual UI of Calendar Pane
function uc_fedex_uc_checkout_pane_shipdate($op, $order, $form = NULL, &$form_state = NULL) {
switch ($op) {
case 'view':
// Check for shipping quote option without altering Ubercart Core.
// The $.get line makes the hook_menu call which in turn
// makes the call back to the above function that has the issue
drupal_add_js("
jQuery(function ($) {
$(document).ready(function() {
last = 'o';
setInterval(function() {
$('#quote input:radio:checked').each(function() {
if($(this).val() != last){
last = $(this).val()
$.get('https://www.fdanconia.com/uc_fedex_jquery_callback/'+ $(this).val());
}
});
}, 500);
});
});", 'inline');
$contents['calendar'] = array(
'#type' => 'textfield',
'#title' => t('Choose Your Estimated Arrival Date'),
'#default_value' => date('m/j/Y',$response[1]),
'#prefix' => '<div id="fromdate">',
'#suffix' => '</div>',
);
return array('description' => $description, 'contents' => $contents);
}
}
// Implements hook_uc_checkout_pane().
function uc_fedex_uc_checkout_pane() {
$panes['calendar'] = array(
'callback' => 'uc_fedex_uc_checkout_pane_shipdate',
'title' => t('Shipping Calendar'),
'desc' => t('A calendar to allow customers to choose shipping date.'),
'process' => TRUE,
);
return $panes;
}
아를 사용하여 시도한 적이 있습니까 –