Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You won't be able to use the <code>$ajax</code> helper here, since it just outputs a static script which can't be changed/influenced at "run-time" in the browser. It just wasn't made for something more complex than it is.</p> <p>So, you'll have to roll your own JS, which shouldn't be that hard though. All you need is:</p> <ol> <li>a Cake action that outputs a list of items based on the data it receives (shouldn't be hard)</li> <li>a bit of JS that figures out which brands and categories are selected (which you already have)</li> <li>another bit of JS that packages that data and sends it to the Cake action</li> <li>another bit of JS that updates the site with the list of items you received back</li> </ol> <p>I'd take a look at <a href="http://api.jquery.com/jQuery.post/" rel="nofollow noreferrer">jQuery's AJAX functions</a> to accomplish #3. If you POST the data in a format like this, it's very easily accessible in <code>$this-&gt;data</code> in Cake:</p> <pre><code>{ 'data[ModelName][categories]' : categories, 'data[ModelName][brands]' : brands } </code></pre> <p>Regarding your question:</p> <blockquote> <p>"How do I pass the js vars into the php method?"</p> </blockquote> <p>You don't. PHP runs on the server and is already finished by the time the Javascript runs in the browser. The only "communication" between JS and PHP is via standard HTTP GET and POST requests, and there it doesn't matter whether the request comes from a standard browser or JS or Flash or whatnot.</p> <p>The <code>$ajax</code> helper just has a bunch of pre-fabricated Javascript snippets it can put into your page, but your JS will not be able to "talk to" the <code>$ajax</code> helper in any way.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload