0

我尝试使用 ajax 通过 jquery 从另一个控制器调用操作。jQuery:

$('.sorting-action').on('click', function (event) {
  event.preventDefault();
  var elem = $(this);
  var root_path = $(this).data('root_path');
  postData = {folder_path: root_path};
  link = location.origin+"/emails-sorting/sorting-files";

  $.ajax({
    type: 'post',
    data: postData,
    url: link,
  });
});

另一个控制器中的操作:

class EmailsSortingController extends AppController
{

public function sortingFiles()
{
    if($this->request->is(['ajax', 'post'])) {
        //Get and check root folder path
        $request_data = $this->request->getData();
        $path = urldecode($request_data['folder_path']);
        $folder_path = $this->emailsFolderBuilder($path);
        if (!empty($folder_path)) {
            //Checking structure of emails folder. There should be 3 folders  country-language, country, language
            $checking_result = $this->folderStructureCheker($folder_path);
            if ($checking_result) {
                $duplicate_list = $this->recordsSorting($folder_path);
            } else {
                $this->Flash->error('Folder structure is incorrect....!!!');
            }
        } else {
            $this->Flash->error('Emails folder does not exist....!');
        }
    }
}

并且总是得到这个错误:POST http://parser/emails-sorting/sorting-files 403 (Forbidden)

4

0 回答 0