owl-carousel slider does not work in my web application - php

i have 2 owl carousel in my page. my problem is one works perfectly but another one. i am using php codeigniter. how to resolve this..i have no idea.how to fix.
1. <script> $(document).ready(function(){ $('#owl-carousel1').owlCarousel({
loop:true,
items:3,
margin:9,
autoplay:true,
autoplayHoverPause:true,
nav:true,
autoplayTimeout:1000,
responsiveClass:true,
responsive:{
0:{
items:1,
nav:true
},
600:{
items:3,
nav:false
},
1000:{
items:3, autoplay:true,
nav:true,
loop:true, slideBy:3,
}
} }); }); </script>
<!----view page---->
<div class="row" style="background-color:#00263A">
<div class="container" style="margin-bottom:50px; margin-top:50px" >
<div class="owl-carousel" id="owl-carousel2" >
<?php
foreach($featuredJobs as $fjobs){ ?> <?php if($fjobs->attachment_url != '' ) {?>
<div class="item"><img src="<?php echo base_url(); ?>files/job_attachment/<?php echo $fjobs->attachment_url;?>"
width="250" height="250" class="responsive" />
<h5><?php echo $fjobs->job_name;?></h5>
<span><?php echo $fjobs->job_categories;?></span> <h6><strong><?php echo
'$'.$fjobs->budget_min.'- $'.$fjobs->budget_max;?></strong></h6>
<a href="<?php if(isset($loggedInUser->id) AND $loggedInUser->id != ''){echo site_url("users/login");}else {
echo site_url("job/createBid/".$fjobs->id);}?>"> <button
type="button" class="btn btn-primary pull-left" title=""><i
class="fa fa-gavel"></i>Bid For This Job</button></a>
</div>
<?php } } ?>
</div>
</div>
</div>

Alright, let me give you some insight. Always cross check your code, your Javascript vs your HTML.
Your first line of your Javascript is:
$(document).ready(function(){ $('#owl-carousel1').owlCarousel({
Yet your HTML is as followed
<div class="owl-carousel" id="owl-carousel2">
See your error already? You refer to owl-carousel2 in the HTML, while your Javascript seeks for instance #owl-carousel1. I leave to you then if you want to change your Javascript or your HTML.

Related

get value from php tag by ajax

i want to get images that i fetched from database in my page and show them again in div with id test by ajax i want to show fetched datas again in div with test id when i click on button with addCart class . i think i haveto get value of button that i set it to ids of products in my datbase . and my problem is how can i get id s in ajax code?
$(document).ready(function(){
$(".addCart").click(function(){
$.post(".addCart.val()",function(data){
$("#test").html(data).show();
});
});
});
<div id="test" style="background-color: grey"></div>
<?php while ($row = mysqli_fetch_array($products)):?>
<div class="span3">
<div class="product">
<div class="product-img">
<div class="picture">
<img src="images/<?php echo $row['image'] ?>" alt="" width="540" height="374" />
<div class="img-overlay">
توضیحات بیشتر
<button value="<?php echo $row['id']?>" class="btn buy btn-danger addCart">اضافه به سبد خرید</button>
</div>
</div>
</div>
<div class="main-titles no-margin">
<h4 class="title"><?php echo $row['price'] ?></h4>
<!--<h5 class="no-margin">محصول ویژه 434</h5>-->
</div>
<p class="desc"><?php echo $row['name']?></p>
<p class="center-align stars">
<span class="icon-star stars-clr"></span>
<span class="icon-star stars-clr"></span>
<span class="icon-star"></span>
<span class="icon-star"></span>
<span class="icon-star"></span>
</p>
</div>
</div> <!-- /product -->
<?php endwhile;?>
$(".addCart").click(function(event){
var id = event.target.val();
});
This will get an value of your button element. But is this id is a valid url to make a ajax call? I dont think so. Please checkout Jquery Docs before returning to work on this part of functionality
in your code you are not passing correct value to php file
please do correction in your code
$(document).ready(function(){
$(".addCart").click(function(){
var jq = $(this);
var cart_id = jq.val(); /* get cart value */
$.post("ajax.php",{cart_id:cart_id},function(data){
$("#test").html(data).show();
});
});
});
and fetch cart_id in php ajax.php file like this
<?php
if(isset($_POST['cart_id'])){
/* put your code here */
}
?>

Change input type number value using jquery

All the other attribute changes seem to work fine inside the modal. The rating button inside the modal doesn't load its value on loading. But the inspect element seems to display the proper rating value.
I am new to php and jquery. Kindly excuse me from silly programming methodologies implemented in the above mentioned code.
Any help would be deeply appreciated.
HTML :
<div class="item" style="width: 400px; height: 230px">
<!-- Link trigger modal -->
<a data-img-url="upload/<?php echo $row['image_name'] ?>" data-toggle=
"modal" href="#myModal" id="<?php echo $row['image_id'] ?>" onclick=
"modalload(this.id, '<?php echo $row['image_title'] ?>' , '<?php echo $row['image_description'] ?>', <?php echo $TAVG ?> );"><img class="img-responsive carousal_scale"
src="upload/%3C?php%20echo%20$row['image_name']%20?%3E"></a>
<div class="carousel-caption">
<p><?php echo $row['image_title'] ?></p>
</div>
</div><!-- Modal -->
<div class="modal fade modal-dialog modal-content" id="myModal" tabindex="-1">
<div class="modal-header">
<button class="close" data-dismiss="modal" type=
"button"><span>×</span><span class="sr-only">Close</span></button>
<h2 class="modal-title" id="myModalLabel"></h2>
</div>
<div class="modal-body well">
<img class="img-responsive carousal_scale" src=""> <input class="rating"
data-size="xs" id="" max="5" min="0" onchange="test(this.id, this.value);"
step="0.1" style="alignment-adjust: auto;" type="number" value="">
</div>
<div>
<p style="text-align: center; font-size: 15px;"></p>
</div>
<div class="modal-footer">
<button class="btn btn-default" data-dismiss="modal" type=
"button">Close</button>
</div>
</div>
JS :
$(document).ready(function() {
$(".rating-kv").rating();
});
function modalload(id, title, description, avg) {
alert(avg);
// alert(description);
$('#myModal img').attr('src', $('#' + id).attr('data-img-url'));
$('#myModal input').attr('value', avg);
$('#myModal input').attr('id', id);
$('#myModal h2').text(title);
$('#myModal p').text(description);
}
function test(id, val) {
var pic_id = id;
var pic_val = val;
$.ajax({
type: 'POST',
url: 'rating.php',
data: {
'pic_id': pic_id,
'pic_val': pic_val
},
}).done(function(data) {
// alert(data);
});
}
"The rating button inside the modal doesn't load its value on loading." You currently have your modalload()function only activate on click of an a tag so your rating isn't going to get it's value/id populated on load, but rather on click.
Try this instead inside your modalload() function,
$('.rating').attr('value', avg);
$('.rating').attr('id', id);
Also, note that there is no jQuery rating() function, and that you have no element with the class rating-kv in your HTML, therefore the below code will do nothing.
$(".rating-kv").rating();
In other words, you have a lot of bad coding practices and incomplete code. You should consider revising what you have and re posting it.

jwplayer audio is not autoplaying in iphone and ipad devices

I am writing below code to play audio using jwplayer
<?php
$extension="m4a";
$audiopath="http://myapp.com/player.php";
?>
<div id="jquery_jplayer_1" class="media" autoplay></div>
<div id="jp_container_1" class="player">
<div class="controls">
<div class="playback">
<i class="icon icon-play"></i>
<i class="icon icon-pause"></i>
</div>
</div>
<div class="controls jp-no-solution">
<div class="playback">
<i class="icon icon-warning-sign warning"></i>
</div>
</div>
</div>
<script>
$(document).ready(function() {
$("#jquery_jplayer_1").jPlayer({
ready: function () {
$(this).jPlayer("setMedia", { "<?php echo $extension ?>": "<?php echo $audiopath ?>" });
$(this).jPlayer("play");
},
supplied: "<?php echo $extension ?>"
});
$("a").click(function(event) {
event.preventDefault();
});
});
</script>
The audio is autoplaying in desktop, but it is not autoplaying in iphone and ipad devices.
Can any one tell me how to fix this problem
There's no PHP in the code snippet. But my guess is your http://localhost/player.php line is the culprit - localhost would be the iPhone/iPad, which probably isn't running a webserver. That should be whatever the actual URL is to the player.php file.
Autostart is disabled by iOS in html5 natively.
Check out our html5 report about this - http://www.jwplayer.com/html5/autoloop/

Undefined constant php error message in laravel

I am new in MVC framework. I created an application in Laravel Framework & it was working fine. Now after some modification when I want to view the index page the following error is shown to me-
Message:
Use of undefined constant php - assumed 'php'
Location:
C:\wamp\www\alpha.team.com\laravel\view.php(354) : eval()'d code on
line 32
Here is my view code of index.blade.php
#layout('/layouts/layout')
<link href='http://fonts.googleapis.com/css?family=Neucha' rel='stylesheet' type='text/css'>
<div id="top">
#section('navigation')
<!-- <li class="active"><i class="icon-user"></i> My Profile</li> -->
<li><i class="icon-book"></i> Dashboard</li>
#parent
#endsection
</div>
#section('content')
<!-- For showing error message if any error occours-->
<?php if(Session::get('error')): ?>
<div class="alert alert-error">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Warning!</strong> <?php echo Session::get('error'); ?>
</div>
<?php endif; ?>
<!-- For showing success message.-->
<?php if(Session::get('success')): ?>
<div class="alert alert-success">
<button type="button" class="close" data-dismiss="alert">×</button>
<strong>Well done!</strong> <?php echo Session::get('success'); ?>
</div>
<?php endif; ?>
<div class="field-section">
<div class="hero-unit">
<!-- <a id="logo" href="#"><img alt="TechIndyeah" src="/uploads/logo.png" style="vertical-align: top;"></a> -->
<h1 style="display:inline;">Team TechIndyeah</h1>
<ul class="teams" style="text-align:center;">
#foreach($departments as $dept)
<?php// print_r($dept); ?>
<li>
<?php echo $dept->name; ?>
</li>
#endforeach
</ul>
</div>
</div> <!-- field-section div ends here-->
<!-- <div class="container"> -->
<div class="wrapper">
<div class="hero-unit" id="bg-pattern">
<h1 class="home-tag"> Tech-ing India<span><p>The team of enthusiastic tech fanatics</p></span></h1>
<p class="home-ptag">We are a team of enthusiastic tech fanatics and yes we are Apple fanboys too. We have sailed out together on a small boat and we do live in what Seth Godin says, “Small is the next big”. We love technology and we love you. Our team is free, creative and always brimming with ideas.</p>
<div class="row" style="background:none;">
<div class="span8">
<h1 class="home-tag" >About Us</h1>
<p class="home-ptag">TechIndyeah has a team which is highly process oriented and has a sharp client-centric approach. Our mission is to help you to build your footprints in business. We are a team inspired by a vision and driven by technology. We are driven by an offbeat approach when it comes to client servicing and support. We have been serving our clients for a long time and have won accolades galore. We are a team and we believe in making our time resourceful so that our clients get the most out of us. We are a band of developers, designers and marketers who can take your business online and also combat the stiff competition from similar players in your domain. </p>
</div>
<div class="span3">
<object type="image/svg+xml" data="/img/logo.svg">
<img alt="TechIndyeah" src="/img/logo.png" style="vertical-align:top;">
</object>
</div>
</div>
<div class="row">
<div class="span4">
<!-- <a id="logo" href="#"><img alt="TechIndyeah" src="/uploads/logo.png"></a> -->
</div>
<!-- <div class="span6" id="caption">
<h3>Here We Are</h3>
</div> -->
</div>
<div class="row">
<?php $something = $errors->all();
if(!empty($something)): ?>
<div class = "alert alert-error">
<button type="button" class="close" data-dismiss="alert">×</button>
#foreach ($errors->all('<p>:message</p>') as $input_error)
{{ $input_error }}
#endforeach
</div>
<?php endif; ?>
</div>
<!-- For showing all employee name in the front page.. Showcasing them..-->
<div id="hero-unit">
<script type="text/javascript">
//The departments are randomly comming in the page when it is first loaded..
(function($) {
// Get the list items and hide them
var items = $(".teams > li").css({opacity:0});
// Shuffle them
shuffle(items);
// Start the fade-in queue
nextItemFade(items);
// Animation callback to start next fade-in
function nextItemFade(items) {
// Fade in the first element in the collection
items.eq(0).animate({opacity:1}, 400, function() {
// Recurse, but without the first element
nextItemFade(items.slice(1));
});
}
// Shuffles an array
// Based on http://jsfromhell.com/array/shuffle
function shuffle(a) {
var j, // Random position
x, // Last item
i = a.length; // Iterator
// Loop through the array
while(i) {
// Select a random position
j = (Math.random() * i) | 0;
// Get the last item in the array
x = a[--i];
// Swap the last item with the item at the selected position
a[i] = a[j];
a[j] = x;
}
return a;
}
/* Minified version
function shuffle(a) {
for(var j, x, i = a.length; i; j = (Math.random() * i) | 0, x = a[--i], a[i] = a[j], a[j] = x);
return a;
} */
})(jQuery);
$(".nav1 li").each(
function(intIndex) {
var l = Math.floor(Math.random() * $(".nav1").width());
var t = Math.floor(Math.random() * $(".nav1").height());
$(this).css("left", l);
$(this).css("top", t);
$(this).on(
"click",
function() {
alert("l=" + l + " t=" + t);
}
);
}
);
$(".nav1 li").each(
function(intIndex) {
var l = Math.floor(Math.random() * 940);
var t = Math.floor(Math.random() * 500);
$(this).css("left", l);
$(this).css("top", t);
$(this).on(
"click",
function() {
alert("l=" + l + " t=" + t);
}
);
}
);
</script>
<style type="text/css">
.nav1
{
position:relative;
}
.nav1 li
{
padding: 10px;
position:absolute;
}
</style>
</div> <!-- #hero-unit ends here-->
<!-- </div> mucarousel div ends here -->
<div class="member-list">
<!-- <object type="image/svg+xml" data="/img/vector-tree2.svg"> -->
<!-- <img alt="TechIndyeah" src="/img/vector-tree2.png" style="vertical-align:top;"> -->
<!-- </object> -->
#foreach($departments as $dept)
<div id="<?php echo implode('_',explode(' ',$dept->name));?>" class="demo">
<ul class="member">
<?php $users = User::where('department_id','=',$dept->id)->get();
// $users = User::where('department_code','=',$dept->code)->get();
?>
#foreach($users as $user)
<li class="new-element" style="display:inline-block;" rel="tooltip" data-placement="right" data-original-title="<?php echo $user->first_name." ".$user->last_name;?>">
<a href="/home/view/<?php echo $user->username;?>" rel="tooltip" data-placement="right" href="#" data-original-title="<?php echo $user->first_name." ".$user->last_name."</br> ".$user->designation;?>">
<img class="hover-img" src="http://graph.facebook.com/<?php echo $user->facebook_id;?>/picture?type=large">
</a>
</li>
#endforeach
</ul>
Back To Top
</div>
#endforeach
<script type="text/javascript">
$(window).scroll(function(){
if ($(this).scrollTop() > 50) {
$('.scrollup').fadeIn();
} else {
$('.scrollup').fadeOut();
}
});
</script>
<script type="text/javascript">
//all links which start with a # will have an animated scroll to the target.
$('a[href^="#"]').on('click.smoothscroll',function (e) {
e.preventDefault();
var target = this.hash,
$target = $(target);
// console.log($target);
$('html, body').stop().animate({
'scrollTop': $target.offset().top - 10
}, 900, 'swing', function () {
window.location.hash = target;
});
});
$('.new-element').children('a').tooltip();
</script>
</div>
<h1 style="text-align:center;font-family: 'Lato light', sans-serif;text-shadow: 2px 1px #848686;">TechIndyeah Software Pvt. Ltd.</h1>
</div>
</div>
#endsection
</div>
I cannot understand. Please help.
I'm not familiar with Laravel, but it seems that an eval() in a file named view.php is rendering a template. So my guess is that someplace in your template (whatever template is being rendered) you have php where you really mean 'php'.
For example:
echo $data[php]; //you have this
echo $data['php']; //but it should be this
//or
if(php == $var){} //you have this
if('php' == $var){} //but it should be this
Can you share some of the code that is in your view.php file?
You're doing something wrong on line 32 of that file, so it would be very helpful if we can see what the code actually is :)

jquery update div background element

Alright not sure what to do and i am honestly bit lost. What I am trying to do is upload a file to site via jQuery and push it to PHP which then deletes original image file and makes a a copy of it called header.jpg and pushes it where it needs to go. That part works with no problem. The problem here is how would I go about updating the div element if the header.jpg image is the background?
Note: no matter what the img will always be header.jpg but it needs to be re-cached by browser and outputed to user without page refresh
Here is how the header div is layed out
<div id="headerEmpty"></div>
<div id="pageName">
<h2><?php echo $pageName; ?></h2>
</div>
<?php if ( $_SESSION['signed_in'] == true ) { ?>
<div id="header" style="background-image:url(uploads/header.jpg);">
<span class="edit" fn="header">
<img src="uploads/icon/16/018.png" />
</span>
<div class="fn_menu" style="display:none;"></div>
</div>
<?php } else { ?>
<div id="header"></div>
<?php } ?>
and here is the jquery bit which displays loader and auto-starts the upload process
$('#photoimg').live('change', function() {
$("#preview").html('');
$("#preview").html('<img src="uploads/icon/16/ajax-loader.gif" alt="Uploading...."/>');
$("#imageform").ajaxForm(
{
target: '#header',
success : function(data) {
$("#header").html(data).fadeIn('fast');
}
}).submit();
});
When you want to update the image, change it's source. You can append a time-stamp to the source so it will not come from the browser's cache. In PHP that would be something like:
<div id="headerEmpty"></div>
<div id="pageName">
<h2><?php echo $pageName; ?></h2>
</div>
<?php if ( $_SESSION['signed_in'] == true ) { ?>
<div id="header" style="background-image:url(uploads/header.jpg?_=<?php echo time(); ?>);">
<span class="edit" fn="header">
<img src="uploads/icon/16/018.png" />
</span>
<div class="fn_menu" style="display:none;"></div>
</div>
<?php } else { ?>
<div id="header"></div>
<?php } ?>
The time-stamp should just be ignored and the image will be downloaded each update.
Update
Ok, I see now that the background image is on the element you are replacing the HTML of. You could use jQuery to update the url() of the image:
success : function(data) {
var theDate = new Date();
$("#header").css('background-image', 'uploads/header.jpg?_=' + theDate.getTime()).html(data).fadeIn('fast');
}
You could also use PHP to output the #header element and use replaceWith() instead of .html():
success : function(data) {
$("#header").replaceWith(data).fadeIn('fast');
}
This assumes that your PHP output now looks like this:
<div id="header" style="background-image:url(uploads/header.jpg?_=1234567890);">
<span class="edit" fn="header">
<img src="uploads/icon/16/018.png" />
</span>
<div class="fn_menu" style="display:none;"></div>
</div>

Categories