-1
<li>
    <a tabindex="-1" class ="accept" id="accept" 
        href="accept.php?claimid=<?php echo$row['claimid']?>">
            Accept
    </a>
</li>

action.php

<?php
    if(isset($_POST['username'])) {
        $action = addslashes($_POST['action']); 
    }
    $sql = "UPDATE claim set 
        username='".$_SESSION['username']."',
        action='accept' 
        where  claimid=".$_GET['claimid']."";
    $result=mysql_query($sql) OR die(mysql_error());
?>

on the page i have action like accept and deny wanna accept here without reoloading page

hjpotter92
  • 78,589
  • 36
  • 144
  • 183
  • 2
    Welcome to Stack Overflow! [Please, don't use `mysql_*` functions](http://stackoverflow.com/q/12859942/1190388) in new code. They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). See the red box? Learn about prepared statements instead, and use [tag:PDO] or [tag:MySQLi]. – hjpotter92 Apr 06 '13 at 08:12
  • You'll find lost of examples of using Ajax on the internet.....In the current context it seems that you want us to code a script for you that you can use. – Jay Bhatt Apr 06 '13 at 08:13

3 Answers3

0

Rather than using an anchor tag, try using a <div> and adding a click event to it which fires off the AJAX event.

HTML

<li><div id="accept">Accept</div></li>

Javascript

$('#accept').click(function() {
  $.ajax({
    url: "accept.php?claimid=<?php echo$row['claimid']?>",
    // ...
    // ...
  });
});

See jQuery .ajax() documentation for more information on what you can pass to the function.

Aiias
  • 4,683
  • 1
  • 18
  • 34
0
$('#accept').click(function() {
                $.GET("/accept.php", { 'claimid': "<?php echo $row['claimid']?>",'username': "<?php echo $_SESSION['username']?>" },
                function(response) {
                    data = response;
                    alert(data)
                });
})

You can echo something in action file, so that output you would get in alert.

Kautil
  • 1,321
  • 9
  • 13
0

Try this:

<div class="accept" data-claim="<?php echo $row['claimid']; ?>">
    Accept
</div>

jQuery

$('div.accept').on('click', function (e) {
    e.preventDefault();
    var MyUrl = 'accept.php';
    $.ajax({
        data: {
            claimid: $(this).data('claim')
        },
        url: MyUrl,
        type: "get",
        success: function (data) {
            alert( "Task complete" );
        }
    });
});

<div class="accept" data-claim="<?php echo $row['claimid']; ?>" style="cursor: pointer; color: blue; text-decoration: underline;">
    Accept
</div>
hjpotter92
  • 78,589
  • 36
  • 144
  • 183