在PHP中访问序列化jQuery [英] access serialize jquery in php

查看:61
本文介绍了在PHP中访问序列化jQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好...我想使用jquery的.serialize()函数,现在我要提交表单,我想使用在我的php文件中传递的值,但是我如何访问它们?这是我的html文件

Hi guys... i would like to use the .serialize() function of jquery i am submitting my form now i want to use that values passed in my php file but how can i access them? heres my html file

<form id="priviledge" method="POST" action="update.php">
        
   <input type="submit"  class= "button_active_red" id="save_new_user" name="save_new_user"/>

   <input type="checkbox" id="can_open_admin" name="can_open_admin" value="test" /><label for ="can_open_admin">Allow access to Admin panel</label>
        
   <input type="checkbox" id="can_modify_useraccount" name="can_modify_useraccount" /><label for ="can_modify_useraccount">Allow user to modify other accounts</label>

</form>



这是我的js代码





and heres my js code



$.ajax({
  type	: "POST",
  url	: "update.php",
  data	: {		
    "formData" : $("#priviledge").serialize() 
	},
  datatype : ''html'',
  success: function(data) {			
	alert(data);
  }
});



现在在我的php文件中,我正在尝试访问该值,但它回显了一个空字符串,这是我的php文件



now in my php file im trying to access the value but it echos an empty string heres my php file

$postForm = $_POST["formData"];
print_r($_POST["formData"]);

echo $_POST["formData"]["can_open_admin"] ;

推荐答案

.ajax({ 类型:"POST", url:"update.php", 数据 : { "formData":
.ajax({ type : "POST", url : "update.php", data : { "formData" :


(#priviledge").serialize() }, 数据类型:"html", 成功:功能(数据){ 警报(数据); } });
("#priviledge").serialize() }, datatype : ''html'', success: function(data) { alert(data); } });



现在在我的php文件中,我正在尝试访问该值,但它回显了一个空字符串,这是我的php文件



now in my php file im trying to access the value but it echos an empty string heres my php file


postForm =
postForm =


这篇关于在PHP中访问序列化jQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆