简体   繁体   中英

Submit form using ajax and pass the value submitted to new page

i have form that need the previous value inserted....i'm using ajax,but the success: function(data) wont let me moved to the next page... here is my code

HTML

<form>
  <input type="text" name="id_1" id="id_1>
  <input type="text" name="id_2" id="id_2>
  <input type="text" name="id_3" id="id_3>
  <button type="button" onclick="next();">
</form>
<div id="tabelna"></div>

JQuery

var id_1 = $('#id_1').val();
var id_2= $('#id_2').val();
var id_3= $('#id_3').val();

var datana = 'id_1='+id_1+'&id_2='+id_2+'&id_3='+id_3; 
var urlna="<?=base_url()?>something/something/something";
$.ajax({
      type: 'POST',
      url: urlna,
      data: datana,
      beforeSend:function(data){
         },
          message:"<center>><h3>Loading Data. . .</h3></center>" 
          }); 
      },
      error: function(data) {
        jAlert('Failed');
      },
      success: function(data) {
        load();
      }    
  })
  return false;
  }
function load()
{
  $('#tabelna').load('<?=base_url()?>something/something/something') (This is my mistake)
}

CONTROLLER

function set_value()
{
 extract($_POST);
 $d['id1']  = $this-db->query('SELECT * FROM TBL1 where id='.$id_1);
 $d['id2']  = $this-db->query('SELECT * FROM TBL2 where id='.$id_2);
 $d['id3']  = $this-db->query('SELECT * FROM TBL3 where id='.$id_3);

 $this->load->view('something/v_add',$d);  (this is my mistake)   
}

How can i pass the submitted value to the controller and shows new form ?

we can call controller function using window.location

function load()
{
window.location.href = "<?php echo site_url('controller_d/login/admin_link_delete_user');?>";
 }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM