Jquery 将序列化的表单值发送到php

Jquery 将序列化的表单值发送到php,jquery,ajax,forms,Jquery,Ajax,Forms,我有这个单选按钮的表格: <form> <input type="radio" name="try" value="radio1" checked="checked" id="r1"/> <label for="r1">radio1</label> <input type="radio" name="try" value="radio2" checked="checked" id="r2"/> <

我有这个单选按钮的表格:

<form>
    <input type="radio" name="try" value="radio1" checked="checked" id="r1"/>
    <label for="r1">radio1</label>

    <input type="radio" name="try" value="radio2" checked="checked" id="r2"/>
    <label for="r2">radio2</label>
</form>

但echo$value没有给出任何东西。因此,我的问题是,如何使用jquery将序列化的值发送到php变量。

您确定请求正在启动并且正确到达服务器吗?我看到两个问题。在代码中,
success
的拼写错误。此外,在您的评论中,您说它返回您的
/sampage?try=radio
,应该是
/samepage.php?try=radio
您确定指向samepage.php的路径正确吗??我在我的本地服务器上检查了您的代码,并且代码工作正常。没有,根本不确定请求是否到达服务器,但正如我在问题中所述,我可以在firebug中看到带有/samepage?try=radio1的响应。我可以用$(“#somediv”).text(str)打印它;这使radio=radio1的路径只是att拼写错误,对此表示抱歉,但这不是问题所在。@user1009453 firebugGET中您得到了什么响应?不,这对我不适用。如果我在提交后导航到samepage.php,我只会收到通知:未定义索引:try。但是如果我手动输入,变量将被回显。结论是$value在通过ajax发送时不会拾取get-regest。我不明白为什么
<form>
    <input type="radio" name="try" value="radio1" checked="checked" id="r1"/>
    <label for="r1">radio1</label>

    <input type="radio" name="try" value="radio2" checked="checked" id="r2"/>
    <label for="r2">radio2</label>
</form>
<div id="result"></div>

<script>
function sendValues() {
    var str = $("form").serialize();
    $.ajax({
        type: "Get",
        url: "samepage.php",
        data: str,
        success : function(data) { //syntax error its success
           $("#result").html(html);
        } 
    }); 
 }
$(":radio").click(sendValues);
sendValues();
</script>
$value = $_GET['try'];
<form>
    <input type="radio" name="try" value="radio1" checked="checked" id="r1"/>
    <label for="r1">radio1</label>

    <input type="radio" name="try" value="radio2" checked="checked" id="r2"/>
    <label for="r2">radio2</label>
</form>
<div id="result"></div>

<script>
function sendValues() {
    var str = $("form").serialize();
    $.ajax({
        type: "Get",
        url: "samepage.php",
        data: str,
        success : function(data) { //syntax error its success
           $("#result").html(html);
        } 
    }); 
 }
$(":radio").click(sendValues);
sendValues();
</script>
echo $value = $_GET['try'];