I found this to start with:
$.ajax({
type: "POST",
url: "some.php",
data: parameters,
success: function(msg){
alert("nothing");
}
});
data
contains parameters as far as I know. My parameters are different depending on what button that is clicked.
My guess is that I could use this
somewhere? But what if I need to send 3 values?
<input type="button" id="unique-1"> <!-- With values 'test', 3 and 5 -->
<input type="button" id="unique-2"> <!-- With values 'doh2', 8 and 6 -->
I use PHP if you need that info.
Thanks!
Check out this fiddle. The button will find the form that it needs to submit, serialize the data, and alert that string. You would just need to then use that string as the parameter for the data option of the ajax call.
Here's another way.
You could do something like this. In each button, put the data (comma-seperated) in a html data attribute. One click: read it, split it, and then send it as an object. On the php side, you'll receive an array of strings for $_GET["data[]"]
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.js"></script>
<input type="button" class="mybutton" data-mydata="1,2,really" />
<script>
$('.mybutton').click(function() {
var parameters = $(this).attr('data-mydata').split(',');
$.ajax({
type: "POST",
url: "some.php",
data: {data:parameters},
success: function(msg){
alert("nothing");
}
});
});
</script>
Fiddle at: http://jsfiddle.net/qdH7s/