Jump to content

kircom

Starter
  • Posts

    1
  • Joined

  • Last visited

Everything posted by kircom

  1. Привет Как написать запрос? JS Code $('#use').on('click', function() { console.log('on click #use'); // console.log('idres= ' + $(this).data('idres')); // var id = $(this).data('idres'); $.ajax({ async: true, type: "POST", cache: false, data: { action: 'clickbtn', id: 100, }, success: function(res) { console.log(res); } }); }); Code template ?php if ( $config->ajax ) { $action = $input->post->action; $res = array(); if ($action == 'clickbtn') : // first ajax call uses POST method $res = array ( 'id' => $page->id , 'title' => $page->title, 'action'=> $action); var_dump($res); return json_encode ($res); else : // second ajax call uses GET method $res['action'] = 'action'; $res['id'] = 'id'; return json_encode($res); endif; // return $this->halt(); } // не ajax, продолжаем обычный вывод страницы ?> But it doesn't work, how to make it work?
×
×
  • Create New...