duangu6588 2014-11-17 17:56
浏览 47

如何使用jquery表单插件发送数据数组?

I'm trying to send an array of data to a php processor page that does some processing tasks such as insertion, etc... but, it seems that the data is not being sent and the php throws this error

The Error:

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

The jquery code that sends the data:

    $(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(); 
        });
    });

The php code that processes the data

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
  • 写回答

1条回答 默认 最新

  • dongqiang5932 2014-11-17 18:43
    关注

    There was a BUG in older jQuery Form pluign when sending data array. Download latest version (atm 3.51.0-2014.06.20).

    评论

报告相同问题?

悬赏问题

  • ¥40 复杂的限制性的商函数处理
  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码