Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/236.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 将数据插入Mysql并在一次单击codeigniter中显示模式_Javascript_Php_Mysql_Ajax_Codeigniter - Fatal编程技术网

Javascript 将数据插入Mysql并在一次单击codeigniter中显示模式

Javascript 将数据插入Mysql并在一次单击codeigniter中显示模式,javascript,php,mysql,ajax,codeigniter,Javascript,Php,Mysql,Ajax,Codeigniter,我有下表: 当我点击“加号”按钮时,我需要将所有字段插入mysql中的一个新表中。在附件中,我需要显示此模式: 在简历中,我需要插入数据并在同一次单击中显示模式 我将MVC与codeigniter一起使用 我可以插入数据并显示模态,如果我独立地这样做的话 要插入数据: 我正在使用控制器,所有参数都是使用URL插入的。 示例:Localhost/Index.php/Controller?参数1和参数2和参数3 要显示模态,请执行以下操作: 我使用onclick=“test()”调用带有ja

我有下表:

当我点击“加号”按钮时,我需要将所有字段插入mysql中的一个新表中。在附件中,我需要显示此模式:

在简历中,我需要插入数据并在同一次单击中显示模式

我将MVC与codeigniter一起使用

我可以插入数据并显示模态,如果我独立地这样做的话

  • 要插入数据:

    我正在使用控制器,所有参数都是使用URL插入的。 示例:Localhost/Index.php/Controller?参数1和参数2和参数3

  • 要显示模态,请执行以下操作:

我使用
onclick=“test()”
调用带有javascript的视图函数,该函数

function test(){$('#myModal').modal('show');}

。或者更简单地说,我可以使用


我不确定我是否理解你的问题。 我想你应该试试ajax调用

$.post( "/Index.php/Controller?Parameter1&Parameter2&Parameter3/", function( data ) {
  $('#myModal').modal('show');
});

如果您愿意,可以尝试使用jQuery,因为它更容易、更简单

$(".plus").on("click",function(e){
    var postData ={};
    var tr = $(this).closest('tr');
    var td = tr.find('td');
    td.each(function(i,v){
        if(i< td.length-1){
            var key = $("#tab").find("th").eq(i).html();   
            postData[key]=$(this).html();
        }
    });
 //Now the parameters are ready send the ajax request
 $.post( "your_url", postData)
  .done(function( data ) {
     $('#myModal').modal('show');
  });
});
$(.plus”)。在(“单击”上,函数(e){
var postData={};
var tr=$(this.nexist('tr');
var td=tr.find('td');
td.每个(功能(i、v){
如果(i
我假设您使用表单,要获取字段,请使用:

    // This product objet to use in ajax
    var myData = $('#ID_FORM').serializeArray();        

    // This send to you page using POST
    $.ajax({
         url: 'test.php',
         data : myData,
         type: "post"
    });

    // Now, i recomend to use http://bootboxjs.com/
    // See docs, using this, look
    // Put data-attribute message in "A" to get it to use in modal box
    // use data-message
    // This plugin, need use bootstrap, is so easy

    $('a').on('click', function(){
        var msg = $(this).data('message');
        bootbox.alert(msg);
    });

我帮了你

你面临的问题是什么?你太棒了!!谢谢,这是工作!