JQuery Passing Variable From href to load()

Posted by dvancouver on Stack Overflow See other posts from Stack Overflow or by dvancouver
Published on 2009-02-01T04:11:18Z Indexed on 2012/09/19 3:38 UTC
Read the original article Hit count: 413

Filed under:

I am trying to pass an href id to load() in JQuery, I can see from the alert the returned id# 960, so I know the id value is getting past I just don't know how to append the load url, well the $("#refreshme_"+add_id) is the important part, I use that to refresh the unique div id in the page assigned by the database pull, so it would be looking for id="refreshme_960". My simple example that is obviously not working. I want to refresh the db select part of the page showing the new list of cars. Any ideas?

$(document).ready(function() 
{
    $(".add_to_favorites").livequery("click", function(event) 
    {
        var add_id = this.id.replace("add_", ""); //taken from a.href tag
        alert (id);
        $.get(this.href, function(data) 
        {
            $("#refreshme_"+add_id).load("http://www.example.com/car_list/"+add_id);


<a class="add_to_cars" href="/car-add/960/add'}" id="add_960">Add Car</a>

© Stack Overflow or respective owner

Related posts about jquery-ajax