[wd_asp elements=’search’ ratio=’100%’ id=1]

Ajax GET/POST Sending Variables

17th July 2013

Jquery - Forms-Posting

jquery icon

$.ajax({
type: 'POST',
url: 'ifpost.php',
data: ({
subject: '',
namefrom: ''
}),
success: function(msg){
alert('wow' + msg);
}
});

Remember to collect the variables the other side…
$subject = mysql_real_escape_string($_POST['subject']);
$namefrom = mysql_real_escape_string($_POST['namefrom']);

Another example
$.ajax({
type: "POST",
url: "callback.php",
data: "{'file':'dave', 'type':'ward'}",
contentType: "application/json; charset=utf-8",
dataType: "json",
});

And then theres the $GET way…

$.get('api.php', 'client=mikescafe', function(data) {
...
});