2017-04-26 103 views
0

我的表單需要插入以前的值....我使用ajax,但成功:函數(數據)不會讓我移動到下一頁...... 這裏是我的代碼使用ajax提交表單並將提交的值傳遞給新頁面

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

控制器

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

如何將提交的值傳遞給控制器​​並顯示新窗體?

回答

0

我們可以使用window.location的

function load() 
{ 
window.location.href = "<?php echo site_url('controller_d/login/admin_link_delete_user');?>"; 
} 
呼叫控制器功能