简体   繁体   English

无法加载Jquery和dataTables

[英]Can't load Jquery and dataTables

I try to use Data Tables, but it's not loading JQuery and DataTables. 我尝试使用数据表,但未加载JQuery和数据表。 I'm trying to use this example: https://datatables.net/examples/basic_init/alt_pagination.html but Data Tables don't load at all, only my table. 我正在尝试使用以下示例: https : //datatables.net/examples/basic_init/alt_pagination.html,但数据表根本不会加载,仅加载我的表。 My code is: 我的代码是:

  <html> <head> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <link rel="stylesheet" href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.min.css" type="text/css" /> <script src="//cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js"></script> <script type='text/javascript'> $(document).ready(function() { $('#example').dataTable( { "pagingType": "full_numbers" } ); } ); </script> </head> <body> <br/><br/> <?php $survey_id = $this->uri->segment(3); echo "<div class='col-md-9'>"; echo '<table border="0" id="example" class="display" cellspacing="0" width="100%">'; echo validation_errors(); foreach ($survey as $row) { echo "<tr>"; echo form_open('index/survey_fill/' .$survey_id ); echo "<td class='col-md-9'>"; echo "$row->question"; echo "</td>"; echo "</tr><tr><td>"; $data=array( 'name' => 'answer['.$row->question_id.']', 'value' => '5' ); echo "<input type='hidden' name='survey_id' value='$row->survey_id'>"; echo "<input type='hidden' name='question_id' value='$row->question_id' />"; echo form_radio($data); echo " 5"; $data=array( 'name' => 'answer['.$row->question_id.']', 'value' => ' 4' ); echo form_radio($data); echo " 4 "; echo "</td></tr><tr>"; } echo "</td></tr><tr><td>"; $data=array( 'name' => 'submit', 'value' => 'send', 'class' => 'btn btn-primary', 'id' => 'survey_submit' ); echo form_submit($data); echo "</td></tr>"; echo form_close(); echo "</table>"; echo "</div>"; echo "</body>"; echo "</html>"; 

What's wrong in my code? 我的代码有什么问题?

I fixed my code and now it shows data tables and each question from my servey is in another row, but when I click submit button, it does not submit any data. 我修复了代码,现在它显示数据表,而我的服务员的每个问题都在另一行中,但是当我单击“提交”按钮时,它不提交任何数据。 My code now is: 我的代码现在是:

 <html> <head> <link rel="stylesheet" href="//cdn.datatables.net/1.10.5/css/jquery.dataTables.min.css" type="text/css" /> <script src="//code.jquery.com/jquery-1.11.0.min.js"></script> <script src="//cdn.datatables.net/1.10.5/js/jquery.dataTables.min.js"></script> <script> $(document).ready(function() { $('#example').dataTable( { "pagingType": "simple", "lengthMenu": [[1], [1]] } ); } ); </script> </head> <body> <br/><br/> <?php $survey_id = $this->uri->segment(3); <table id="example" > <thead> <tr><th>Въпрос</th></tr> </thead> <tbody> <?php echo validation_errors(); foreach ($survey as $row) { $row->question_id=$this->uri->segment(4); $question_id=$this->uri->segment(4); ?> <tr> <?php $attributes = array('id' => 'myform'); echo form_open('index/survey_fill/' .$survey_id , $attributes); ?> <td> <?php echo "$row->question"; ?><br/> <?php echo "<input type='hidden' name='question_id' value='$row->question_id' />"; ?> $data=array( 'name' => 'answer['.$row->question_id.']', 'value' => '5' ); echo "<input type='hidden' name='survey_id' value='$row->survey_id'>"; ?> <?php echo "<input type='hidden' name='question_id' value='$row->question_id' />"; echo form_radio($data); echo " 5 "; $data=array( 'name' => 'answer['.$row->question_id.']', 'value' => ' 4' ); echo form_radio($data); echo "4 "; ?> </td></tr> <?php } ?> <tr><td> <?php ?> <input type="submit" id="button" name = "submit" value="Submit"> </td></tr> <?php echo form_close(); ?> </tbody> </table> </body> </html> 

My model is: 我的模型是:

 $answers=($this->input->post('answer')); if (null !==($this->input->post('submit'))) { $date = new DateTime("now"); foreach($answers as $question_id=>$answer) { $data = array( 'user_id'=>$this->session->userdata['user_id'], 'question_id'=>$question_id, 'answer'=>$answer, 'created_at'=>$date->format('Ymd H:i:s') ); $this->db->insert('survey_answers', $data); } if($this->db->affected_rows() > 0) { return true; } return false; } 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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