【发布时间】:2014-11-17 17:56:38
【问题描述】:
我正在尝试将数据数组发送到执行某些处理任务(例如插入等)的 php 处理器页面...但是,似乎没有发送数据并且 php 抛出此错误
错误:
Notice: Undefined index: reci in C:\Users\YASIN\Desktop\SERVER\htdocs\drawer_mess_page_process.php on line 67
Warning: array_map(): Argument #2 should be an array in C:\Users\YASIN\Desktop\SERVER\htdocs\drawer_mess_page_process.php on line 67
发送数据的jquery代码:
$(document).ready(function () {
var reci_arr = [];
var i = 0;
$('.recipient_tab').each(function(){
var a = $(this).attr('data-recipient');
reci_arr[i++] = $(this).attr('data-recipient');
});
var time=new Date().getTime();
var options = {
url:'processor.php',
type:'POST',
resetForm:true,
data:{reci:reci_arr,time:time},// the data reci is not being sent other data is being sent
beforeSend:function(html){
},
success:function(html) {
//doing stuffs which works
},
};
$('#hide_selector_mess_draw').change(function()
{
$('#add_photo_mess_draw').ajaxForm(options).submit();
});
});
处理数据的php代码
function clean_arr ($a)
{
$db = mysqli_connect("localhost", "root", "stark1998" ,"users") or die("Could not connect database");
return mysqli_real_escape_string($db, $a);
}
$reci= array_map('clean_arr', $_POST['reci']);//to_acc
【问题讨论】:
-
在 js 中你发送两个参数,键为 reci 和 time,在服务器端你问 vor $_POST['recipie'] - 输入错误,缺少代码?
-
@axel.michel 不,这是一个错字,但我认为 .each 函数没有被调用
标签: php jquery arrays forms plugins