Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Since you're using Dojo, you might as well use its built-in <a href="http://dojotoolkit.org/documentation/tutorials/1.6/ajax/" rel="nofollow">Ajax</a> functionality...</p> <p>And the following is kind of weird :</p> <pre><code>$input=$_GET["input"]; if($input=$_GET["input"]){ </code></pre> <p>First of all, you should use the proper Zend Framework methodology, ie. use <code>$this-&gt;_getParam('input');</code> instead of accessing the $_GET/$_POST/$_REQUEST counterparts.</p> <p>So replace it with :</p> <pre><code>$input = $this-&gt;_getParam('input'); if (!is_null($input)) { </code></pre> <p>And then for your actual problem (well I guess anyway): to return data from your AJAX call you most likely should make sure that the Zend Framework will not render the data using a view template (unless of course you would make a separate .phtml that returns the data in the proper format). So you should turn off the view renderer using <code>$this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender();</code> and if you're using the layout manager, disable that too <code>$this-&gt;_helper-&gt;layout()-&gt;disableLayout();</code>. And at the end of the script return the data in the format that is expected by your client-side script (most likely JSON).</p> <p>So to summarize, your Ajax search action code should probably be as follows :</p> <pre><code>$this-&gt;_helper-&gt;viewRenderer-&gt;setNoRender(); $this-&gt;_helper-&gt;layout()-&gt;disableLayout(); // fetch params &amp; process, store results in $results $this-&gt;getResponse()-&gt;setBody(Zend_Json::encode($results)); </code></pre> <p>Oh BTW you should consider using a separate action for the actual ajax search if possible, instead of mixing it in the action that displays/processes your search form...</p>
    singulars
    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. This table or related slice is empty.
    1. This table or related slice is empty.
    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