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

时间:2014-11-17 17:56:39

标签: php jquery arrays forms plugins

我正在尝试将一组数据发送到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

1 个答案:

答案 0 :(得分:0)

发送数据阵列时,旧的jQuery Form插件中有一个BUG。下载最新版本(atm 3.51.0-2014.06.20)。