由网友(狙杀.)分享简介:我想一个变种,从传递到jQuery的PHP。 研究后,我发现最常见的建议是这样与发表与Ajax和使用PHP存储后变种。 我的PHP技能pretty的不错,但我不能说我的JavaScript技能相同。 这是我在做什么,但似乎并没有在所有的工作:// jQuery的libray包括等等等等<脚本>$阿贾克斯({...![年轻真香 无极限](https://p.xsw88.cn/allimgs/daicuo/20230910/1399.png)
我想一个变种,从传递到jQuery的PHP。
研究后,我发现最常见的建议是这样与发表
与Ajax和使用PHP存储后变种。
我的PHP技能pretty的不错,但我不能说我的JavaScript技能相同。
这是我在做什么,但似乎并没有在所有的工作:
// jQuery的libray包括等等等等
<脚本>
$阿贾克斯({
键入:POST,
网址:http://currentpage.com
数据:VAR =价值,
数据类型:字符串
});
< / SCRIPT>
< /头>
<身体GT;
< PHP
如果($ _ REQUEST [变种] ==值){
回声变种通过与存储;
}
?>
解决方案
<脚本>
$阿贾克斯({
键入:POST,
网址:的index.php
数据:{VAR:值},
数据类型:文本,
成功:功能(数据){
//测试什么是从服务器返回
警报(数据);
}
});
< / SCRIPT>
![年轻真香 无极限](https://p.xsw88.cn/allimgs/daicuo/20230910/1399.png)
I am trying to pass a var from jQuery to PHP.
After researching I found the most common suggestion was to do this with Post
with Ajax and store the post var using PHP.
My PHP skills are pretty good but I can't say the same about my JavaScript skills.
This is what I am doing but does not seem to work at all:
// jquery libray included etc etc
<script>
$.ajax({
type: "POST",
url: "http://currentpage.com",
data: "var=value",
dataType: string
});
</script>
</head>
<body>
<?php
if($_REQUEST["var"] == "value") {
echo "var passed and stored";
}
?>
解决方案
<script>
$.ajax({
type: "POST",
url: "index.php",
data: {var:'value'},
dataType: 'text',
success:function(data){
// Test what is returned from the server
alert(data);
}
});
</script>
相关推荐
最新文章