1 2 3 4 5 6 7 8 9 10 11 12 13 |
$.ajax({ type: 'POST', url: 'ifpost.php', data: ({ subject: '<?php echo $subject ?>', namefrom: '<?php echo $namefrom ?>' }), success: function(msg){ alert('wow' + msg); } }); |
Remember to collect the variables the other side…
1 2 3 4 |
$subject = mysql_real_escape_string($_POST['subject']); $namefrom = mysql_real_escape_string($_POST['namefrom']); |
Another example
1 2 3 4 5 6 7 8 9 |
$.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…
1 2 3 4 5 |
$.get('api.php', 'client=mikescafe', function(data) { ... }); |