Note that there are some explanatory texts on larger screens.

plurals
  1. POform submissions with AJAX
    primarykey
    data
    text
    <p>So here is my problem in localhost. I am passing in the search parameter to my Home controller like:</p> <pre><code>&lt;form method="post" action="&lt;?=site_url('home/index');?&gt;"&gt; </code></pre> <p>When I do this, my ajax menu is populated correctly</p> <pre><code> ---------- SEARCH:| mot | ---------------------------- | motorcyles ... | | motorhomes ... | | motorola .. | ----------------------------- </code></pre> <p>.</p> <p>On my web server, the only way to submit the form is with <code>&lt;form method="post" action="&lt;?site_url('home/index');?&gt;"&gt;</code> if I put the "=" in there, it does nothing. If I use</p> <pre><code>&lt;?php echo site_url('home/index');?&gt;"&gt; </code></pre> <p>it will also display nothing.</p> <p>Additionally, when I type in search terms on my web server</p> <pre><code> ---------- SEARCH:| mot | --------- </code></pre> <p>nothing, no errors, no results. If I submit the form, I get back the correct results only after pressing submit.</p> <p>My controller is getting the correct results from the database, here is how I'm encoding my results array:</p> <pre><code>if ( $this-&gt;input-&gt; is_ajax_request()) { $this-&gt;output-&gt;set_header("Cache-Control: no-cache, must-revalidate"); $this-&gt;output-&gt;set_header("Expires:Mon, 4 Apr 1994 04:44:44 GMT"); $this-&gt;output-&gt;set_header("Content-type:application/json"); echo json_encode($results); exit(); } else { $data['results'] = $results; } </code></pre> <p>There are no errors with my js file. I have CSRF turned off. Why is this happening?</p> <pre><code>$(document).ready(function() { var action= $('form').attr('action'); var results = $('#results'); function ajax_search(search) { $.post(action, { search: search }, function(data) { if(data.length) { var el = $('&lt;ul/&gt;'); $.each(data,function(i,item){ $(el).append('&lt;li&gt;&lt;span class="Course_Name"&gt;' + item.course_name_highlighted + '&lt;/span&gt; &amp;ndash; &lt;span class="FirstName"&gt;' + item.FirstName + '&lt;/span&gt; &amp;ndash; &lt;span class="LastName"&gt;' + item.LastName + '&lt;/span&gt; &amp;ndash; &lt;span class="COURSE_ID"&gt;'+item.COURSE_ID +'\n&lt;/span&gt;&lt;/li&gt;'); }); $(results).empty().append(el); } else{ $(results).empty(); } }, 'json'); } $('#search').keyup(function() { var search = $(this).val().replace(/^\s+l\s+$/g, ""); if(search.length &gt; 1) { clearTimeout($.data(this, 'timer')); var wait = setTimeout(function() { ajax_search(search) }, 400); $.data(this,'timer', wait); } }); }); </code></pre>
    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.
 

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