Can I make something like this for example?
$.ajax({
url:'ajax.php',
type:'POST',
data: {
id: 3,
device: $("#ipole4").val(),
name: $("#ipole5").val(),
ip: $("#ipole6").val(),
method: $("#ipole7").val(),
if (2 == 2) {
'info':2
}
},
})
I just want to send something more in the special case.
You can do this, but not with the syntax you have. You need to create the object first, then use the condition statement separately, like this:
var data = {
'id': 3,
'device': $("#ipole4").val(),
'name': $("#ipole5").val(),
'ip': $("#ipole6").val(),
'method': $("#ipole7").val()
};
if (2 == 2)
data.info = 2;
$.ajax({
url:'ajax.php',
type:'POST',
data: data
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With