我是Codeigniter的新手。 我试图将Ajax查询表单用于我的产品详细信息视图,并希望将表单详细信息保存到详细信息到db表(查询)中。但是每次我收到错误消息。
Failed to load resource: the server responded with a status of 404 (Not Found) - send_inq
请告诉我一种解决方法。
这些是我的Controller,Ajax和视图编码
控制器
public function send_inq(){
$data = array(
'ref_id' => $this->input->post('ref_prod'),
'customer_name' => $this->input->post('customer_name'),
'customer_email' => $this->input->post('customer_email')
);
$this->db->insert('inquiries', $data);
}
Ajax
<!--Ajax Submit-->
<script type="text/javascript">
$(document).ready(function(){
$("#send-inquiry").submit(function(e){
e.preventDefault();
var ref_prod = $("#ref_prod").val();
var customer_name = $("#customer_name").val();
var customer_email = $("#customer_email").val();
$.ajax({
type: "POST",
url: '<?php echo base_url() ?>products/send_inq',
data: {ref_prod:ref_prod, customer_name:customer_name, customer_email:customer_email},
success:function(data)
{
alert('Thanks...Your message sent successfully...We will keep in touch with you soon!!');
},
error:function()
{
alert('Sorry..!!! Your message is not submitted.');
}
});
});
});
</script>
查看
<form action="" method="POST" id="send-inquiry" name="send-inquiry">
<div class="row">
<div class="col-sm-12">
<div class="form-group">
<input type="text" name="ref" class="form-control" id="ref_prod" value="<?php echo $product_item['product_name']; ?>(<?php echo $product_item['product_code']; ?>)" readonly>
</div><!-- End .form-group -->
</div><!-- End .col-sm-6 -->
<div class="col-sm-12">
<div class="form-group">
<input type="text" name="customer_name" class="form-control" id="customer_name" placeholder="Name*" required>
</div><!-- End .form-group -->
</div><!-- End .col-sm-6 -->
<div class="col-sm-12">
<div class="form-group">
<input type="text" name="customer_no" class="form-control" id="customer_no" placeholder="Mobile*" required>
</div><!-- End .form-group -->
</div><!-- End .col-sm-6 -->
<div class="col-sm-12">
<div class="form-group">
<input type="email" name="customer_email" class="form-control" id="customer_email" placeholder="E-mail*" required>
</div><!-- End .form-group -->
</div><!-- End .col-sm-6 -->
</div><!-- End .row -->
<div class="form-group mb20">
<textarea cols="30" name="comment" rows="5" id="comment" placeholder="Remark..." class="form-control"></textarea>
</div>
<div class="text-right">
<input type="submit" id="submit-p" name="submit-p" class="btn btn-accent min-width" value="Submit">
</div><!-- End .text-right -->
</form>