With $.post, you can send information to the server, but what when you need to receive information from the server?
How does information change from being of a way that can be held by a php variable to being of a way that can be held by a javascript variable and vice-versa?
This is more relevant to your question: http://docs.jquery.com/Ajax/jQuery.post
Alert out the results from requesting test.php (HTML or XML, depending on what was returned).
$.post("test.php", function(data){
alert("Data Loaded: " + data);
});
Alert out the results from requesting test.php with an additional payload of data (HTML or XML, depending on what was returned).
$.post("test.php", { name: "John", time: "2pm" },
function(data){
alert("Data Loaded: " + data);
});
Gets the test.php page content, store it in a XMLHttpResponse object and applies the process() JavaScript function.
$.post("test.php", { name: "John", time: "2pm" },
function(data){
process(data);
}, "xml");
Gets the test.php page contents which has been returned in json format ("John","time"=>"2pm")); ?>)
$.post("test.php", { func: "getNameAndTime" },
function(data){
alert(data.name); // John
console.log(data.time); // 2pm
}, "json");
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