我有一个小调查,但当我提交它时,它说消息为空,我看不出我的错误在哪里。
如果你能帮我的话,我很感激。
谢谢你
带有Jquery和Ajax函数的My Form
<!DOCTYPE HTML><hmtl lang=“pt pt”><头部><title>形式;里约</title><script type=“text/javascript”src=“http://code.jquery.com/jquery-1.4.2.min.js“></script></头><body><小时/><h3>Formulario公司</h3><script type=“text/javascript”charset=“utf-8”>$(函数(){$(“#提交者”).click(function(){$.ajax(美元)({类型:“POST”,url:“validar.php”,dataType:“json”,成功:功能(消息){警报(“Mensagem”+消息消息);},错误:函数(){警报(“Ocorreu um erro”);}});});});</script><form id=“formulario”action=“”method=“post”accept-charset=“utf-8”><p>佩尔贡塔1</p><label for=“pergunta1”>sim</label><input type=“radio”id=“p1”name=“pergunta1”value=“1”/><br/><label for=“pergunta1”>nã;o</label><input type=“radio”id=“p1”name=“pergunta1”value=“0”/><br/><p>佩尔贡塔2</p><label for=“pergunta2”>sim</label><input type=“radio”name=“pergunta2”value=“0”/><br/><label for=“pergunta2”>nã;o</label><input type=“radio”name=“pergunta2”value=“1”/><br/><p>佩尔贡塔3</p><label for=“pergunta3”>sim</label><input type=“radio”name=“pergunta3”value=“0”/><br/><label for=“pergunta3”>nã;o</label><input type=“radio”name=“pergunta3”value=“1”/><br/><p>佩尔贡塔4</p><label for=“pergunta4”>sim</label><input type=“radio”name=“pergunta4”value=“0”/><br/><label for=“pergunta4”>n和atilde;o</label><input type=“radio”name=“pergunta4”value=“1”/><br/><p><input type=“submit”id=“submiter”value=“Continue&rarr;”></p></form></body></html>
我的PHP
<?php(电话)如果($_POST){$pergunta1=$_POST['porgunta1'];$pergunta2=$_POST['porgunta2'];$pergunta3=$_POST['porgunta3'];$pergunta4=$_POST['porgunta4'];$calcular=$pergunta1+$pergunti2+$pergonta3+$pergutta4;$var=数组('mensage'=>$calcular);echo json_encode($var);}其他{$var2=数组('mensage'=>'sem resultado');echo json_encode($var2);}?>