samedi 11 avril 2015

Send a button value with jQuery Ajax

I have a litle problem with the following code:



<script type="text/javascript">
$(document).ready(function()
{
$("#click").click(function()
{
var jegy = $(this).attr('value');
var dataString = $( "#jegyform" ).serialize();

$.ajax
({
type: "POST",
url: "jegybeiras.php",
data: dataString + '&jegy=' + jegy,
cache: false,
success: function(html)
{
$("#jegyek").html(html);
}
});

});
});
</script>


And a form where is the following buttons (and other inputs)



<button id="click" name="jegy" type="submit" value="p5">5</button><button id="click" name="jegy" type="submit" value="p4">4</button><button id="click" name="jegy" type="submit" value="p3">3</button><button id="click" name="jegy" type="submit" value="p2">2</button><button id="click" name="jegy" type="submit" value="p1">1</button>


My question is that, how can I post the clicked button value, it is working now but randomly for 4th-5th clicking on the actual button.


Aucun commentaire:

Enregistrer un commentaire