You need to do string concatenation, since first_id
and second_id
are variables you need to create a concatenated string like 'id=' + first_id + '&id2=' + second_id
as the parameter
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel();
$("a.inline").colorbox({iframe:true, width:"80%", height:"80%"});
$("#opposition a").click(function(e) {
var first_id = $(this).attr('id'); // value of first_id is 10
var second_id = $("h1").attr('id'); // value of second_id is 20
$("div#test").load('compare_proc.php','id=' + first_id + '&id2=' + second_id);
e.preventDefault();
});
});
Another option is to pass the data as an object instead of string as given below, I prefer this method
jQuery(document).ready(function() {
jQuery('#mycarousel').jcarousel();
$("a.inline").colorbox({iframe:true, width:"80%", height:"80%"});
$("#opposition a").click(function(e) {
var first_id = $(this).attr('id'); // value of first_id is 10
var second_id = $("h1").attr('id'); // value of second_id is 20
$("div#test").load('compare_proc.php',{
id:first_id,
id2:second_id
});
e.preventDefault();
});
});