开发者

Troubles using jquery get to retrieve data from the server and place in a div

开发者 https://www.devze.com 2023-01-24 01:08 出处:网络
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.

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 开发者_如何学Python+ '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!


Do you have firebug installed so you can check that the get is being fired?

maybe you can change this to echo debug string to test the problem is not in the model.

function get_venue_description($venueID){
    echo 'This is a test responce';
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号