【发布时间】:2013-04-26 21:07:03
【问题描述】:
我有以下表格:
HTML:
<form name="NewProductForm" id="NewProductForm" action="http://localhost/tddd27/index.php/AddProduct/AddToDatabase">
<br><label>Product Name:</label>
<input name="ItemName" type="text"/></br>
<br><label>Category:</label>
<input name="ItemCategory" type="text"/></br>
<br><label>Description:</label>
<input name="ItemDesc" type="text"/></br>
<br><label>Price:</label>
<input name="Price" type="text"/></br>
<input type="text" name="ID" value="<?php echo $ID; ?>" hidden="true" >
<input type="text" name="Name" value="<?php echo $Name; ?>" hidden="true">
<input type="button" id="_NewProduct" name="_NewProduct" value="Submit">
</form>
当用户点击一个按钮 jQuery 提交这个表单。
jQuery:
$("#_NewProduct").click(function(){
$("#NewProductForm").submit();
});
表单调用一个调用模块的 CodeIgniter 控制器,并将产品插入数据库中。之后我想加载另一个视图。于是我写了:
function AddToDatabase()
{
$ItemName=$_GET['ItemName'];
$ItemCategory=$_GET['ItemCategory'];
$ItemDesc=$_GET['ItemDesc'];
$ID=$_GET['ID'];
$Price=$_GET['ItemDesc'];
$this->load->model('AddProductModule');
$this->AddProductModule->AddProductOnTable($ItemName,$ItemCategory,$ItemDesc,$ID,$Price);
$data=array('ID' => $_GET['ID'], 'Name' => $_GET['Name']);
$this->load->view ( 'adminview',$data);
exit;
}
问题是load->view 似乎没有加载视图。提交后一切顺利,产品在数据库中,但加载了一个空页面而不是adminview。知道是什么问题吗?
【问题讨论】:
-
Y 最后有
exit;??? -
我不知道 CodeIgniter 但我想说
exit是你的问题。
标签: php jquery forms codeigniter