No Refresh

Discussion in 'JavaScript' started by Barry67, Sep 26, 2010.

  1. #1
    Hi,

    I have 2 links which will insert information into a database.

    <?php
            $q = mysql_query("SELECT * FROM favourites WHERE username = '$username' AND offerid = '$oID'") or die(mysql_error());
            $r = mysql_fetch_array($q);
            if (empty($r)) {
                echo '<a href="addfavourite.php?offerid=' . $list['id'] . '&username=' . $ofusername . '"><img src="template/images/afav.png" alt="Add Icon" border="0" /> Favourite</a>';
            }else {
                echo '<a href="removefavourite.php?offerid=' . $list['id'] . '&username=' . $ofusername . '"><img src="template/images/rfav.png" alt="Add Icon" border="0" /> Favourite</a>';
            } 
    ?>
    PHP:
    Is there anyway I can get the link to update with addfavourites.php/removefavourite.php without refreshing the page?
     
    Barry67, Sep 26, 2010 IP
  2. GFX_Lover

    GFX_Lover Peon

    Messages:
    60
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Of course!

    Use AJAX, preferably jQuery.

    $.get('removefavourite.php?**aruguments**', function(data){ $("#result").html(data)});
     
    GFX_Lover, Oct 3, 2010 IP