Append variables to Jquey.post
I'm using post for sending data to a PHP page. My problem is that sometimes I need to append some more variables to the POST statement and I wanna use the same function.
The basic is:
-
$.post( 'mypage.php', {
var1: 'data',
var2: 'data'
},
function() {
$('#obj').html(data);
});
But sometimes I need:
-
$.post( 'mypage.php', {
var1: 'data',
var2: 'data',
var3: 'data',
var4: 'data'
},
function() {
$('#obj').html(data);
})
Is there a way to use the same function for doing this?