Why my DataTable jQuery cant load on my table view? - javascript

This is the code for the script,
but it's not working please help me.
<script>
function loading(){
$("#loading").removeAttr("hidden");
}
$(function () {
//Initialize Select2 Elements
$(".select2").select2();
$("#example1").DataTable();
});
</script>
This is the code for the script, but its not working please help me.
<script src="<?php echo base_url()?>public/jquery-1.12.3.min.js"></script>
<script src="<?php echo base_url()?>public/bootstrap/js/bootstrap.min.js"></script>
<script src="<?php echo base_url()?>public/app.min.js"></script>
<!-- DataTables -->
<script src="<?php echo base_url()?>public/datatables/jquery.dataTables.min.js"></sc‌ript>
<script src="<?php echo base_url()?>public/datatables/dataTables.bootstrap.min.js"><‌​/script>
<!-- Select2 -->
<script src="<?php echo base_url()?>public/plugins/select2/select2.full.min.js"></sc‌​ript>
this image is the console error please click here

I Fix it on my Own..
I have a "colspan= 2" in the view table and i have a extra "td" in my code thanks to all your comment.

Related

Owl Carousel with Magnific Popup - Popup not even displaying, not sure what I'm doing wrong

I'm using Magnific Popup for my Owl Carousel Slider. I just want the images to pop-up on screen. However, it doesn't seem to be working. The only thing it does it when I click the images, it opens up its src link. But I just want the Magnific Popup. Am I importing the files wrong? Am i formatting wrong? I've tried so much and can't seem to get the Magnific Popup to even display...
HTML/PHP
<div class="owl-carousel owl-theme details_banner">
#forelse($home_images as $image_model)
#php
$real_image = public_path('uploads/frontend/home/' . $image_model->name);
$image = asset('public/uploads/frontend/home/' . $image_model->name);
if (!file_exists($real_image)) {
$image=DEFAULT_IMG;
}
#endphp
<a class="popup1" href="<?php echo $image ?>"><img src="<?php echo $image ?>"/></a>
#empty
<a a class="popup1" href="<?php echo DEFAULT_IMG ?>"><img src="<?php echo DEFAULT_IMG ?>"/></a>
#endforelse
</div>
Javascript
<script type ="text/javascript">
$(document).ready(function() {
$('.popup1').magnificPopup({
type: 'image',
closeOnBgClick :true,
enableEscapeKey: true
});
});
</script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="vendor/Magnific-Popup-master/dist/jquery.magnific-popup.min.js"></script>
I put this at the top of my file
<link rel="stylesheet" href="{{asset('public/frontend/css/owl.carousel.min.css')}}" />
<link href="{{asset('public/backend/css/jquery-confirm.min.css') }}" rel="stylesheet">
<!-- Magnific Popup core CSS file -->
<link rel="stylesheet" href="vendor/Magnific-Popup-master/dist/magnific-popup.css" media="screen"/>
Solved by putting these 2 lines above my Magnific Function
<script src="//ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/magnific-popup.js/1.1.0/jquery.magnific-popup.min.js"></script>

bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6

i make control panel and there is a problem with jquery (data-toggle) not working and this message appear in console" bootstrap.min.js:6 Uncaught Error: Bootstrap's JavaScript requires jQuery at bootstrap.min.js:6 "
this is footer file
<div calss="footer">
</div>
<script src="<?php echo $js; ?>jquery-3.2.1.min.js"></script>
<script src="<?php echo $js; ?>jquery-ui.min.js"></script>
<script src=" <?php echo $js; ?>bootstrap.min.js"></script>
<script src="<?php echo $js; ?>jquery.selectBoxIt.min.js"></script>
<script src="<?php echo $js; ?>backend.js"></script>
</body>
</html>
and i include footer
include $tpl.'footer.php';
and thats working in main site with the same folders and pathes and names
i dont know whats wrong
Try this
Change the order of files it should be like below..
<script src="<?php echo $js; ?>jquery-3.2.1.min.js"></script>
<script src="<?php echo $js; ?>bootstrap.min.js"></script>
<script src="<?php echo $js; ?>jquery-ui.min.js"></script>
<script src="<?php echo $js; ?>jquery.selectBoxIt.min.js"></></script>
<script src="<?php echo $js; ?>backend.js"></script>

JQuery function is not called in PHP CodeIgniter

Iam new in php. I am trying to popup login window on click.but it is not working
This is my header_view
<head>
<script type="text/javascript" language="javascript" src="<?php echo base_url();?>Assets/js/popuplogin.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url();?>Assets/js/jquery.min.js"></script>
</head>
<body>
<div id="rightcorner">
<a href="#" id="loginlink" >Log In</a>
</div>
</body>
I included the below code in home.php(controller)
$this->load->library('javascript');
$this->load->library('javascript/jquery');
$this->load->helper(array('form'));
$data['library_src'] = $this->jquery->script();
$data['script_head'] = $this->jquery->_compile();
below is my popuplogin.js
$(document).ready(function() {
$("#loginlink").click(function(){
$("#logindiv").css("display","block");
});
When I click on loginlink nothing happened.
Pls help me.

difficulties on locating javascript and css codeigniter

Hi how can i aces in view model
i saved my css and javascript inside the js folder and css folder inside the application in codeigniter how can i aces it i'm having difficulties to link them
www
application
-jsfolder
-jsfiles
-cssfolder
-cssFiles
<?php
//birds.php
class Birds extends CI_Controller{
function index(){
$this->load->view('birds_view');
}
function get_birds(){
$this->load->model('birds_model');
if (isset($_GET['term'])){
$q = strtolower($_GET['term']);
$this->birds_model->get_bird($q);
}
}
}
<?php
//birds_model.php
class Birds_model extends CI_Model{
function get_bird($q){
$this->db->select('bird');
$this->db->like('bird', $q);
$query = $this->db->get('birds');
if($query->num_rows > 0){
foreach ($query->result_array() as $row){
$row_set[] = htmlentities(stripslashes($row['bird'])); //build an array
}
echo json_encode($row_set); //format the array into json data
}
}
}
}
bird_view.php
<style>
.ui-autocomplete-loading {
background: #fff url('../link/to/ajax-loading-image') right center no-repeat !important;
}
</style>
<link href="<?php echo base_url().'css/' ?>./css/jquery.ui.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo base_url().'js/'?>/js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url().'js/'?>/js/jquery.ui.js"></script>
<input type="text" id="birds" />
<script>
$(function(){
$("#birds").autocomplete({
source: "birds/get_birds" // path to the get_birds method
});
});
</script
it only display white screen tnx in advance guys
You should link your css and js file as:-
<link href="<?php echo base_url().'css/jquery.ui.css'; ?>" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo base_url().'js/query.js'; ?>"></script>
<script type="text/javascript" src="<?php echo base_url().'js/jquery.ui.js'; ?>"></script>
do your really need that 'dot' after your closing php tag?
<?php echo base_url(); ?>./
also remove extra leading slashes:
<link href="<?php echo base_url(); ?>css/jquery.ui.css" />
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.js"></script>
<script type="text/javascript" src="<?php echo base_url(); ?>js/jquery.ui.js"></script>
p.s make sure that base_url is set properly in your config file: $config['base_url']='localhost/websitename/'
with a trailing slash

Wordpress Conditional Javascript Include

I am trying to conditionally include javascript files on specific pages in wordpress. I finally found a snippet of code that does exactly what I want but it doesn't seem to be working. Any thoughts? I didn't include the real page names but I am using the page slug.
<?php if (is_page(array('page-slug','page-slug','page-slug'))) { ?>
<script src="<?php echo get_template_directory_uri(); ?>/js/script.js"></script>
<? } else { ?>
<script src="<?php echo get_template_directory_uri(); ?>/js/script.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/conditional-script.js"> </script>
<? } ?>
I Put this code where I call the rest of my scripts in my custom template files.
On third last line and last line, it looks like you are using <? to open the line. Try using <?php instead. So, it should be:
<?php
if (is_page(array('page-slug','page-slug','page-slug')))
{ ?>
<script src="<?php echo get_template_directory_uri(); ?>/js/script.js"></script>
<?php
}
else
{ ?>
<script src="<?php echo get_template_directory_uri(); ?>/js/script.js"></script>
<script src="<?php echo get_template_directory_uri(); ?>/js/conditional-script.js"></script>
<?php
}
?>
And as I mentioned, I would recommend enqueuing scripts in the future ;)

Categories