Ajax To Update Database Via Function
I am trying to update some data in my database using AJAX. I have already made the php script and tested that it is indeed working. I need to pass two variables to the php script w
Solution 1:
<scripttype="text/javascrip">functionupvote(memeid, userid)
{
$.ajax({
url : 'scripts/upvote.php', // give complete url here
type : 'post',
data : 'id='+memeid+'&userid='+userid,
success : function(msg){
alert('success');
}
});
});
</script>
You didnt passed the second argument for upvote function.
echo'<img id="upvote" onclick="upvote('.$feed[$loaded]["memid"].','.$feed[$loaded]["userid"].')" src="images/neutral_up.png" width="20px">';
Solution 2:
You should read jQuery's documentation : http://api.jquery.com/jQuery.ajax/
Your line "var myData = ..."
is incorrect, replace it by data : { (key : value object)
} (for further details, refer to the documentation)
Solution 3:
syntax error
$.ajax({
url : 'scripts/upvote.php?id='+memeid+'&'+userid, // give complete url here
type : 'post',
data:{'id' : 'id...'},
success : function(data){
alert('success');
}
});
Solution 4:
<script type="text/javascrip">
function upvote(memeid, userid)
{
$.ajax({
url : 'scripts/upvote.php
type : 'post',
data = {member_id:memeid, user_id:userid},
success : function(data){
alert('success');
}
});
});
</script>
In php You can get the datas using $_POST['member_id'] & $_POST['user_id']
Post a Comment for "Ajax To Update Database Via Function"