I have a code shown below and test.php file. My question is how to retrieve name and time in the php file?
$.post("test.php", { name: "John",开发者_运维技巧 time: "2pm" } );
Yes, the values will be in $_POST. IN your example $_POST['name']
will include John
Yes. $_POST["name"]
would be "John"
and $_POST["time"]
would be "2pm"
. Similarly, if you had used $.get
in jQuery, the data would be in $_GET
in PHP.
Yes, you'll find the data you've posted to the server in the $_POST
collection.
Did you try this to find out? What were your results?
Then you can place the response text(something you print in test.php
) with this code
$.post("test.php", { name: "John", time: "2pm" },function(responseText){//do what you want with variable 'responseText' here});
精彩评论