js无法post关联数组到php?index.htm代码:<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<script type="text/javascript">
function hello(){
arr=[];
arr["a"]=["1","2"];
arr["b"]=["hello","world"];
$.ajax({
url:"laji.php",
type:"post",
data:{
arr:arr
},
success:function(d){
alert(d);
}
})
}
function hello2(){
arr=[];
arr[0]=["1","2"];
arr[1]=["hello","world"];
$.ajax({
url:"laji.php",
type:"post",
data:{
arr:arr
},
success:function(d){
alert(d);
}
})
}
</script>
<button onclick="hello()">hello</button>
<button onclick="hello2()">hello2</button>laji.php代码:<?php
$arr=$_POST["arr"];
print_r($arr);
?>运行hello1()出错运行hello2()正常
怎么样才能传送关联数组?
<script type="text/javascript">
function hello(){
arr=[];
arr["a"]=["1","2"];
arr["b"]=["hello","world"];
$.ajax({
url:"laji.php",
type:"post",
data:{
arr:arr
},
success:function(d){
alert(d);
}
})
}
function hello2(){
arr=[];
arr[0]=["1","2"];
arr[1]=["hello","world"];
$.ajax({
url:"laji.php",
type:"post",
data:{
arr:arr
},
success:function(d){
alert(d);
}
})
}
</script>
<button onclick="hello()">hello</button>
<button onclick="hello2()">hello2</button>laji.php代码:<?php
$arr=$_POST["arr"];
print_r($arr);
?>运行hello1()出错运行hello2()正常
怎么样才能传送关联数组?
解决方案 »
- 将字符串分成两部分
- php DOM getElementsByTagName_r()???
- 关于SNS网站的个性化信息如何存储和调用?
- set_magic_quotes_runtime 对哪些数据或行为产生作用?当magic_quotes_gpc为on的话,print 表单变量,必须手动stripslashes吗?
- 时间问题!急(在线等待.......)
- 老大们:如何获取<input type="file" name="upfile">中的内容,包括完整的路径和文件名!我都快急死了,快来帮帮我啊!我等了好久好久,就
- mysql的root的密码怎么改呀?
- linux 下 php & mysql 启动应用
- MySQL中为什么没有布尔类型的数据类型?
- 急。 我在apache环境下写的php可以运行,可以将数据库数据输出到网页上。 把文件放到IIS服务器下面。。什么东西都不出了。。什么原因?
- PHP判断~!问题!在线等!急
- 关于XAMPP和ZEND
hello 提交的数组竟然为空 hello2 方法竟然是正常的·~~~寻找答案···