当我单击一个按钮时,它会创建一个变量$ var,然后我想将此var发送给php来处理它。
示例:
Jquery.js中的$('#button').click(function(){
//create the var
$name = "abcde";
//send the $name to process.php
---I DONT KNOW HOW---
});
只是...
echo $name;
如何发送$ name ???
答案 0 :(得分:2)
答案 1 :(得分:2)
$.get("url", {name: "abcde"}, function(response){
//Do something
});
$.post("url", {name: "abcde"}, function(response){
//Do something
});
答案 2 :(得分:0)
$.post('process.php',name:$name,function(data){alert(data);});
in process.php
if(isset($_POST['name'])){
echo $_POST['name'];
}else{
echo 'nothing was send';
}
答案 3 :(得分:0)
$('#button').click(function(){
var $name = "abcde";
$.ajax({
type: 'POST',
url: process.php,
data: {name:$name},
success: function(data){alert("send ok")}
});
});
process.php:
if(isset($_POST['name'])){
echo $_POST['name'];
}