开发者

How to retrieve Jquery post values in PHP file?

开发者 https://www.devze.com 2023-03-16 14:15 出处:网络
I have a code shown below and test.php file. My question is how to retrieve name and time in the php file?

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});

0

精彩评论

暂无评论...
验证码 换一张
取 消