SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Guru
    Join Date
    Mar 2006
    Posts
    701
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    set the content of a div via jquery

    I try to update the content of a div with ajax and jquery and it does not work.What is the error?
    Code:
    <div class="video7" id="video7">
     0 <a id="like7" onclick="return statuslike('7','/testdrive/control/videoslike','video7')"
     href="#"> like </a></div>
    Code:
    function  statuslike(id,url,div)
    {    var options = {
            type: 'POST',
            url:url,
            data: 'cid='+id,
            success: function (data, textStatus, jqXHR)
            {
            $('#'+div).replaceWith(data);
            }     }   
        $.ajax(options);
        return false;        
           
    }

  2. #2
    SitePoint Guru hifigrafix's Avatar
    Join Date
    Oct 2005
    Location
    Nashville, TN
    Posts
    628
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perhaps your problem lies in:
    $('#'+div).replaceWith(data);
    I'd use
    $('#'+div).html(data);


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •