click(function() { var status = $("#activitymessage"). val(); var name = "Ronny"; $. ajax({ type: "POST", url: "ajax/activity_save. php", **data: "status="+status+"name="+name"**, success: function(msg) {...
function getInfo(val1, val2) { $. ajax({ type: "POST", url: "get_info. php", data: 'value1='+val1+'&value2'+val2, success: function(data){ $("#info"). html(data); } }); };
Use just setTimeout(executeQuery, 5000); instead of setTimeout('executeQuery()', 5000); - it's shorter and faster.
The correct syntax is:
data: {status: status, name: name},
As specified here: http://api.jquery.com/jQuery.ajax/
So if that doesn't work, I would alert those variables to make sure they have values.
You can send data through JSON or via normal POST, here is an example for JSON.
var value1 = 1;
var value2 = 2;
var value3 = 3;
$.ajax({
type: "POST",
contentType: "application/json; charset=utf-8",
url: "yoururlhere",
data: { data1: value1, data2: value2, data3: value3 },
success: function (result) {
// do something here
}
});
If you want to use it via normal post try this
$.ajax({
type: "POST",
url: $('form').attr("action"),
data: $('#form0').serialize(),
success: function (result) {
// do something here
}
});
Try with quotes:
data: {"status": status, "name": name}
It must work fine.
var countries = new Array();
countries[0] = 'ga';
countries[1] = 'cd';
after that you can do like:
var new_countries = countries.join(',')
after:
$.ajax({
type: "POST",
url: "Concessions.aspx/GetConcessions",
data: new_countries,
...
This thing work as JSON string format.
According to http://api.jquery.com/jquery.ajax/
$.ajax({
method: "POST",
url: "some.php",
data: { name: "John", location: "Boston" }
})
.done(function( msg ) {
alert( "Data Saved: " + msg );
});
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