【问题标题】:View does not load after form submission through jQuery通过jQuery提交表单后视图不加载
【发布时间】: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-&gt;view 似乎没有加载视图。提交后一切顺利,产品在数据库中,但加载了一个空页面而不是adminview。知道是什么问题吗?

【问题讨论】:

  • Y 最后有exit;???
  • 我不知道 CodeIgniter 但我想说exit 是你的问题。

标签: php jquery forms codeigniter


【解决方案1】:

你不想在控制器方法运行后退出...Codeigniter 在那之后还有事情要做。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多