I am new to jquery and I am having problems trying to retrieve an item from the database and display the results. I am using codeigniter php.
What i am trying to do is this. I do a search, the search returns a list of posible results which is displayed in a div called venue_description. Onclick of one of the items from the list, I want it to replace the list with the item that is being clicked upon. but for some reason it does not work
In order to do that I did this:
In my model I pass the id of the item that is being clicked upon on the list through the onclick function
<--- this is in venue_model.php -->
$output .= '<li><a href="#self" class="menulink" class=&{ns4class}
. ' onClick="changeDiv(\'' . $venue_details->VenueID . '\')">
The venueID
is passed through the changeDiv
which is in the divUpdater.php
This is where the problem is. The $.get
doesn't work. Can someone see the mistake? The Item retrieved is to be displayed in venue_description
div
<script type="text/javascript">
base_url = '<?= base_url(); ?>index.php/';
</script>
<script type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script type="text/javascript">
function changeDiv(venueID) {
$.get(base_url + 'home/get_venue_description/' + venueID, function(data) {
$('#venue_description').html(data);
});
}
</script>
changeDiv(venueID)
calls the get_venue_description(venueID)
in the home.php
controller to retrieve the specific item from the database.
function get_venue_description($venueID){
echo $this->venue_model->retrieveData($venueID);
}
Can anyone see the problem in this code? I have spent too much time try to find the mistake. Please help!