Getting JQuery to do the equivalent of a GET form submit
Hello all
I have a couple of simple forms:
-
<form action="insert.php">
<input type="hidden" name="action" value="vote_up">
<input type="hidden" name="id" value="' . $name_row[mpid] . '">
<input type="submit" value="Up">
</form>
<form action="insert.php">
<input type="hidden" name="action" value="vote_down">
<input type="hidden" name="id" value="' . $name_row[mpid] . '">
<input type="submit" value="Down">
</form>
which work great, but I'm trying to replace the form buttons with jQuery images. The action (insert.php) takes the variables through GET.
Now I have the following jQuery code:
-
$.ajax({
type: "GET",
data: "action=vote_down&id="+$(this).attr("id"),
url: "insert.php",
success: function(msg)
{
$("span#votes_count"+the_id).fadeOut();
$("span#votes_count"+the_id).html(msg);
$("span#votes_count"+the_id).fadeIn();
$("span#vote_buttons"+the_id).remove();
}
});
..but it doesn't work, because it's not passing the variables correctly I don't think. I don't know how to simulate a simple GET posting of a form.. the data line in this code is from another script which uses POST, but POST doesn't work for my purposes so I have to use GET.
Any thoughts? Help would be much appreciated!