request - how do basic jquery ajax in typo3 flow? -


i trying basic ajax. want onchange event on select call ajax function options select , fill in. not sure how in simple way in typo3 flow. php code action looks this:

 public function getproductsbycategoryaction(  $category='' ) {          $postarguments = $this->request->getarguments();          echo __line__;          typo3\flow\var_dump($postarguments);  die; } 

and ajax call looks this:

jquery('#get_category').change(function(event) {         event.preventdefault();         alert('get products');         var category  = jquery('#get_category').val();         alert(category);         jquery.ajax({               url: "/admin/orders/getproductsbycategory.html",             data: {                 'category': category                             },             async: true,             datatype: 'html',             success: function(data) {                 alert('hi mom');                 ...              }         });     }); 

when try url in browser mysite-dot-com/admin/orders/getproductsbycategory.html?category=17ca6f3e-a9af-da7d-75cd-20f8d6a05ed0 on page var_dump gives me array(empty). why doesn't request->getarguments() call work , give category argument?

the getproductsbycategory.html created in neos , has right plugin action call. know right action gets run not args. @ point argument string , not _identity though should way, i'm trying keep things simple sake of expediency.

thanks

update: temp workaround shameless hack did variable:

$categoryid = $_get['category']; 

which works i'd know proper way if not involve writing own view helpers.

first define variable in html file

<script> var ajaxurl = '<f:uri.action action="actionname" controller="(controllername)ajax"/>'; </script> 

your ajax code :->

$.ajax({     data: '&lookup='+{somevalue},     type: 'post',     url: ajaxurl,     success: function(data) {         $('.lookup-id').append(data);     }, });  

your conroller action :->

public function getlookupidaction(){      // company detail set logo of company     $companydetail = $this->getusercompany();      // template name     $templatename = 'getlookupid.html';     $viewvariables = $this->lookupidentifierrepository->findbycompany($companydetail);     $templatepath = 'resource://wind.alertregistration/private/templates/lookupidentifier/' . $templatename;     $this->standaloneview->setlayoutrootpath('resource://wind.alertregistration/private/layouts');     $this->standaloneview->setpartialrootpath('resource://wind.alertregistration/private/partials');     $this->standaloneview->setformat('html');     $this->standaloneview->settemplatepathandfilename($templatepath);     $this->standaloneview->assignmultiple(array("lookupvalue" => $viewvariables));     $this->standaloneview->setcontrollercontext($this->getcontrollercontext());      return $this->standaloneview->render(); } 

your view file :->

<f:layout name="lookup" /> <f:section name="content">     <label for="lookupid" style="box-sizing: border-box;">identifier</label>     <div class="select-box" style="box-sizing: border-box;">          // code      </div> </f:section> 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -