Jquery';错误请求';在url中传递数组时出错

Jquery';错误请求';在url中传递数组时出错,jquery,ajax,json,codeigniter,Jquery,Ajax,Json,Codeigniter,我有一个数组,里面有10多条记录,我想把它传递给控制器,但它会弹出错误,说请求不正确 以下是我的代码: $('#submit_fourth').click(function(){ //send information to server $.ajax({ type: 'POST', url: '<?php print site_url('orgnization/storeData'); ?>/'

我有一个数组,里面有10多条记录,我想把它传递给控制器,但它会弹出错误,说请求不正确

以下是我的代码:

$('#submit_fourth').click(function(){
        //send information to server
             $.ajax({
            type: 'POST',
            url: '<?php print site_url('orgnization/storeData'); ?>/'+fields


        });

    });
$('submit_fourth')。单击(函数(){
//将信息发送到服务器
$.ajax({
键入:“POST”,
url:“/”+字段
});
});
如代码所示,
字段
是包含数据的数组。下面是firebug中的错误消息


有什么帮助吗?

您正在以错误的格式发送数据数组。请参阅下面的示例

$.ajax({
  type: "POST",
  url: "<?php print site_url('orgnization/storeData'); ?>",
  data: { name: "John", location: "Boston" }//your data will send in this format
})
$.ajax({
类型:“POST”,
url:“”,
数据:{name:“John”,location:“Boston”}//您的数据将以这种格式发送
})

您正在以错误的格式发送数据数组。请参阅下面的示例

$.ajax({
  type: "POST",
  url: "<?php print site_url('orgnization/storeData'); ?>",
  data: { name: "John", location: "Boston" }//your data will send in this format
})
$.ajax({
类型:“POST”,
url:“”,
数据:{name:“John”,location:“Boston”}//您的数据将以这种格式发送
})

您正在以错误的格式发送数据数组。请参阅下面的示例

$.ajax({
  type: "POST",
  url: "<?php print site_url('orgnization/storeData'); ?>",
  data: { name: "John", location: "Boston" }//your data will send in this format
})
$.ajax({
类型:“POST”,
url:“”,
数据:{name:“John”,location:“Boston”}//您的数据将以这种格式发送
})

您正在以错误的格式发送数据数组。请参阅下面的示例

$.ajax({
  type: "POST",
  url: "<?php print site_url('orgnization/storeData'); ?>",
  data: { name: "John", location: "Boston" }//your data will send in this format
})
$.ajax({
类型:“POST”,
url:“”,
数据:{name:“John”,location:“Boston”}//您的数据将以这种格式发送
})

如果要发送GET请求,请尝试以下操作:

$data = array('foo'=>'bar',
              'baz'=>'boom',
              'cow'=>'milk',
              'php'=>'hypertext processor');


echo site_url('orgnization/storeData') . '?' . http_build_query($data);
type:'POST'
更改为
type:'GET'

如果您想发送邮件:

$.post("<?php print site_url('orgnization/storeData'); ?>", <?php echo json_encode($data); ?>)
   .done(function( data ) {
      alert( "Data Loaded: " + data );
});
$.post(“,”)
.完成(功能(数据){
警报(“数据加载:”+数据);
});

如果要发送GET请求,请尝试以下操作:

$data = array('foo'=>'bar',
              'baz'=>'boom',
              'cow'=>'milk',
              'php'=>'hypertext processor');


echo site_url('orgnization/storeData') . '?' . http_build_query($data);
type:'POST'
更改为
type:'GET'

如果您想发送邮件:

$.post("<?php print site_url('orgnization/storeData'); ?>", <?php echo json_encode($data); ?>)
   .done(function( data ) {
      alert( "Data Loaded: " + data );
});
$.post(“,”)
.完成(功能(数据){
警报(“数据加载:”+数据);
});

如果要发送GET请求,请尝试以下操作:

$data = array('foo'=>'bar',
              'baz'=>'boom',
              'cow'=>'milk',
              'php'=>'hypertext processor');


echo site_url('orgnization/storeData') . '?' . http_build_query($data);
type:'POST'
更改为
type:'GET'

如果您想发送邮件:

$.post("<?php print site_url('orgnization/storeData'); ?>", <?php echo json_encode($data); ?>)
   .done(function( data ) {
      alert( "Data Loaded: " + data );
});
$.post(“,”)
.完成(功能(数据){
警报(“数据加载:”+数据);
});

如果要发送GET请求,请尝试以下操作:

$data = array('foo'=>'bar',
              'baz'=>'boom',
              'cow'=>'milk',
              'php'=>'hypertext processor');


echo site_url('orgnization/storeData') . '?' . http_build_query($data);
type:'POST'
更改为
type:'GET'

如果您想发送邮件:

$.post("<?php print site_url('orgnization/storeData'); ?>", <?php echo json_encode($data); ?>)
   .done(function( data ) {
      alert( "Data Loaded: " + data );
});
$.post(“,”)
.完成(功能(数据){
警报(“数据加载:”+数据);
});
试试这个:

$('#submit_fourth').click(function(){
        //send information to server
             $.ajax({
            type: 'POST',
            data: {fields:fields},
            url: '<?php print site_url('orgnization/storeData'); ?>/'
           success: function(data)
            {
                  console.log('Success');
            }

            });

        });
试试这个:

$('#submit_fourth').click(function(){
        //send information to server
             $.ajax({
            type: 'POST',
            data: {fields:fields},
            url: '<?php print site_url('orgnization/storeData'); ?>/'
           success: function(data)
            {
                  console.log('Success');
            }

            });

        });
试试这个:

$('#submit_fourth').click(function(){
        //send information to server
             $.ajax({
            type: 'POST',
            data: {fields:fields},
            url: '<?php print site_url('orgnization/storeData'); ?>/'
           success: function(data)
            {
                  console.log('Success');
            }

            });

        });
试试这个:

$('#submit_fourth').click(function(){
        //send information to server
             $.ajax({
            type: 'POST',
            data: {fields:fields},
            url: '<?php print site_url('orgnization/storeData'); ?>/'
           success: function(data)
            {
                  console.log('Success');
            }

            });

        });
在发布数据之前使用JSON.stringify();并在数据中给出,不要在url中追加

$('#submit_fourth').click(function(){
    //send information to server
         $.ajax({
        type: 'POST',
        url: '<?php print site_url('orgnization/storeData'); ?>/',
        data: JSON.stringify(fields)


    });

});
$('submit_fourth')。单击(函数(){
//将信息发送到服务器
$.ajax({
键入:“POST”,
url:“/”,
数据:JSON.stringify(字段)
});
});
在发布数据之前使用JSON.stringify();并在数据中给出,不要在url中追加

$('#submit_fourth').click(function(){
    //send information to server
         $.ajax({
        type: 'POST',
        url: '<?php print site_url('orgnization/storeData'); ?>/',
        data: JSON.stringify(fields)


    });

});
$('submit_fourth')。单击(函数(){
//将信息发送到服务器
$.ajax({
键入:“POST”,
url:“/”,
数据:JSON.stringify(字段)
});
});
在发布数据之前使用JSON.stringify();并在数据中给出,不要在url中追加

$('#submit_fourth').click(function(){
    //send information to server
         $.ajax({
        type: 'POST',
        url: '<?php print site_url('orgnization/storeData'); ?>/',
        data: JSON.stringify(fields)


    });

});
$('submit_fourth')。单击(函数(){
//将信息发送到服务器
$.ajax({
键入:“POST”,
url:“/”,
数据:JSON.stringify(字段)
});
});
在发布数据之前使用JSON.stringify();并在数据中给出,不要在url中追加

$('#submit_fourth').click(function(){
    //send information to server
         $.ajax({
        type: 'POST',
        url: '<?php print site_url('orgnization/storeData'); ?>/',
        data: JSON.stringify(fields)


    });

});
$('submit_fourth')。单击(函数(){
//将信息发送到服务器
$.ajax({
键入:“POST”,
url:“/”,
数据:JSON.stringify(字段)
});
});