Note that there are some explanatory texts on larger screens.

plurals
  1. POtrouble having a javascript code retrieve data from mysql
    primarykey
    data
    text
    <p>I am in a little bit of a predicament. I am writing a programme where a user can make a search. Then the search returns a possible list of results. If you move your mouse over the results it highlights them. When you select one of the items from the result, it replaces the list with the item you selected. The problem I am having is that I can't get the item to replace the list. I am using CodeIgniter.</p> <p><strong>Steps</strong></p> <p>In my model, I pass the id (VenueID) of item through onclick function to my javascript function.</p> <p><em>venue_model.php</em>:</p> <pre><code>$output .= '&lt;li&gt;&lt;a href="#self" class="menulink" class=&amp;{ns4class}; onClick="changeDiv(\''. $venue_details-&gt;**VenueID**. '\')"&gt; </code></pre> <p>The javascript function takes the javascript id and then passes it to a function in the controller to retrieve the item from a MySQL database.</p> <p><em>divUpdater.php</em>:</p> <pre><code>&lt;script type="text/javascript"&gt; base_url = '&lt;?= base_url();?&gt;index.php/'; &lt;/script&gt; &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; function changeDiv(venueID){ $.get(base_url+'home/get_venue_description/' + venueID , function(data) { $('#venue_description').html(data); document.getElementById('venue_description').innerHTML=data; }); } </code></pre> <p>here is the function from the controller that retrieves the data from the database</p> <p><em>home.php</em> (controller)</p> <pre><code> function get_venue_description($venueID){ echo $this-&gt;venue_model-&gt;retrieveData($venueID); } </code></pre> <p>The problem is in the model and the divUpdater.php. When I click on one of the item from the list, it gives me this url </p> <pre><code>http://localhost/Counter/index.php#self </code></pre> <p>And this is becasue of the anchor tag in the model (<code>&lt;a href="#self"...</code>). I was wondering if it was possible to get the code in the divUpdater.php to execute and retrieve the data in the background without having the url change. </p> <p>Please does anyone know how to do that?</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.
 

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