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).

    评论

报告相同问题?

悬赏问题

  • ¥100 set_link_state
  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度