Javascript doesn't work on ajax call - php

I've got a problem with working JS in the Ajax call.
The JS works normaly until I get the new data from database or when I get ajax call.
Ajax call works normaly, just Javascript does not load.
Please help.
Here is the example index.php.
<!-- library -->
<script type="text/javascript" src="js/deleting_data.js"></script>
<link href="css/forme.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" src="js/funkcije.js"></script>
<link rel="stylesheet" type="text/css" href="css/dinamicno_iskanje.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.ausu-autosuggest.min.js"></script>
<div id="load" align="center"><img src="images/loading.gif" width="28" height="28" align="absmiddle"/> Loading...</div>
<div id="seek">//here comes refreshed data, with ajax call
<table class="content" style="border-collapse: separate; border-spacing: 0px 5px; ">
<?php
while($row=mysql_fetch_array($query))
{
//data from database
</table></div>
<div id="delete"></div> //ajax call for deleting data
And here is the refreshed_data.php
<!-- library -->
<script type="text/javascript" src="js/deleting_data.js"></script>
<link href="css/forme.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" src="js/funkcije.js"></script>
<link rel="stylesheet" type="text/css" href="css/dinamicno_iskanje.css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.ausu-autosuggest.min.js"></script>
<div id="load" align="center"><img src="images/loading.gif" width="28" height="28" align="absmiddle"/> Loading...</div>
<table class="content" style="border-collapse: separate; border-spacing: 0px 5px; ">
<?php
while($row=mysql_fetch_array($query)
{
//refreshed data
?>
</table>
<div id="delete"></div>//ajax call for deleting data
And here is the deleting_data.js, whick works normaly when the page is loaded.
$(document).ready(function () {
//$(".gumb").live("click",function(){
$('#load').hide();
$('#brisanje').hide();
});
$(function () {
//$(".gumb").click(function() {
$(".gumb").live("click", function () {
$('#load').fadeIn();
$('#brisanje').fadeIn();
$(this).parent().parent().fadeOut(1000, function () {
$(this).remove();
});
$('#load').fadeOut();
$('#brisanje').fadeOut(1000);
});
});

If you are looking for javascript to fire based on an elemenet created from an AJAX call, you need to remember your order of operations. For example: If you fired a .click event assignemnt at time 0, and then ajax some content at time 4 which produces a type that matches the parameters of the click event, it will not have the .click property assigned. It is because the script to assign the click event was not applied to that element. It would need to be reapplied by calling that .click function again.

live() is depracated since jQuery 1.7
Try to use on() instead, like this :
$('rootselector').on('click', 'selector', function(){
...
});
With your code :
$(document).on('click', '.gumb', function() {
// your stuff
})
And for the record, you're including jQuery twice :
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.0/jquery.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>

Related

Uncaught TypeError: $(...).modal

why can't view modal ?
and error like this
it should be like this
You should try this way:
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<!-- BS JavaScript -->
<script type="text/javascript" src="js/bootstrap.js"></script>
<!-- Have fun using Bootstrap JS -->
<script type="text/javascript">
$(window).load(function() {
$('#prizePopup').modal('show');
});
</script>
Answer
<script type="text/javascript" src="https://code.jquery.com/jquery-1.11.3.min.js"> </script>
<script type="text/javascript"
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
<script type="text/javascript">
// jQuery
$('.edit_real').on('click', function (event) {
event.preventDefault();
$('#edit_real').modal();
});
</script>

jQuery star rating plugin not working in PHP

I have tried to integrate jQuery star rating plugin called jQuery master in to my PHP application, but its not working. Can anyone help me? Below is my code:
{literal}
<!-- include CSS & JS files -->
<!-- CSS file -->
<link rel="stylesheet" type="text/css" href="jRatingmaster/jquery/jRating.jquery.css" media="screen" />
<!-- jQuery files -->
<script type="text/javascript" src="<?php echo CONST_SITE_ADDRESS;?>jRatingmaster/jquery/jquery.js"></script>
<script type="text/javascript" src="<?php echo CONST_SITE_ADDRESS;?>jRatingmaster/jquery/jRating.jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
// alert('hi');
// get the clicked rate !
$(".basic").jRating({
onClick : function(element,rate) {
alert(rate);
}
});
});
</script>
{/literal}
<div class="exemple">
<div class="basic" data-average="8" data-id="2"></div>
</div>
Firstly, run your page in Mozilla FireFox, and check if any javascript/CSS file is not getting included.
In the Net tab, it shows a 404 with red color.
In the code, <?php echo CONST_SITE_ADDRESS;?> will not work in Smarty as it is being seen from your code.
From your PHP file, assign this to some variable display it in template.
<script type="text/javascript" src="<?php echo CONST_SITE_ADDRESS;?>jRatingmaster/jquery/jquery.js"></script>
<script type="text/javascript" src="<?php echo CONST_SITE_ADDRESS;?>jRatingmaster/jquery/jRating.jquery.js"></script>
So, the corrected code:
<script type="text/javascript" src="{$YOUR_PATH}jRatingmaster/jquery/jquery.js"></script>
<script type="text/javascript" src="{$YOUR_PATH}jRatingmaster/jquery/jRating.jquery.js"></script>
As per the documentation specified, there is no onclick handler in jrating plugin.
Your code should be like,
<script type="text/javascript">
$(document).ready(function(){
$(".basic").jRating();
});
</script>

jquery tooltip Help Needed

How to write php code(variable) in tooltip
Here is my code:-
<head>
<link type="text/css" rel="stylesheet" href="css/screen.css" media="screen" />
<script type="text/javascript" src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script type="text/javascript" src="js/chilltip-packed.js"></script>
<script type="text/javascript">
$(function() {
$('.ChillTip').ChillTip();
$('.ChillTip1').ChillTip({
CTBK:'#fff',
CTBC:'#000',
CTW:'150'
});
});
</script>
</head>
<body>
<?php
$abc= 'Urvisha';
?>
For more info.
<button class="ChillTip" title="This is a button example">BUTTON</button>
</body>
I want the $abc in my tooltip
if i am writing $abc inside title="" then $abc is displaying not its value
plz help me.....
You just need to echo the variable into the HTML:
<button class="ChillTip" title="<?php echo $abc?>">BUTTON</button>

jQuery autocomplete result should appear like combo box

The response has about 500 records and it looks ugly in auto-complete. If more than 10 suggestion then is there any change make the list look like combobox instead of very long list?
Thanks
<html>
<head>
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css" rel="stylesheet" type="text/css"/>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript">
$(document).ready(function()
{
$('#textbox_postcode').autocomplete(
{
source: 'search-db.php',
minLength: 3
});
});
</script>
</head>
<body>
<input type="text" id="textbox_postcode" value="" />
</body>
</html>
add the following to your .css file.
.ui-autocomplete {
max-height: 100px !important;
overflow-y: scroll;
}
max-height can be whatever you would like.

JQmodal pop up can not appear

I've a problem about jqmodal. That pop up can not appear. My scenario is any data in variable warning, pop up will appear and will appear the all warning data.
This the code. Please help me. Thanks
<link type="text/css" rel="stylesheet" href="<? echo base_url().'css/jqmodal/css/prettify.css'; ?>" />
<script type="text/javascript" language="JavaScript" src="<? echo base_url().'css/jqmodal/';?>js/prettify.js"> </script>
<link type="text/css" rel="stylesheet" href="<? echo base_url().'css/jqmodal/';?>css/jquery.modaldialog.css" />
<script type="text/javascript" language="JavaScript" src="<? echo base_url().'css/jqmodal/';?>js/jquery.js"> </script>
<script type="text/javascript" language="JavaScript" src="<? echo base_url().'css/jqmodal/';?>js/jquery.modaldialog.js"> </script>
<script type="text/javascript" language="JavaScript">
$().ready(function(){
prettyPrint();
});
</script>
if(#$warning != NULL)
{
?>
<div id="jqModal" class="jqmWindow" style="display: none;"></div>
<script type="text/javascript">
jQuery().ready(function($){
$('#jqModal').jqm({onShow:setText});
$('#jqModal').jqmShow();
function setText(){
$('#jqModal').text(<?php echo #$warning;?>);
}
});
</script>
<?php
Hey Ayu I built a small demo for you Demo http://jsfiddle.net/BG42j/
Now if you will click on the view... in above demo you will get the text I am setting in my setText function. Rest you can play around with the demo. And please don't forget to accept the answer if this helps. :) Your accept ration is very low :)
Helpful link: http://dev.iceburg.net/jquery/jqModal/
So I reckon issue was the way setText is declared is not correct /* callback executed when a trigger click. Show notice */ onShow (callback): Called when a dialog is to be shown. Be sure to show (set visible) the dialog.
Hope this helps and have a nice one! cheers
Jquery Code
$(document).ready(function() {
$('#dialog').jqm({onShow:setText});
// $('#dialog').jqm().jqmShow({overlay: 70});
});
var setText = function(h) {
/* callback executed when a trigger click. Show notice */
h.w.text('Warning! foooooo');
h.w.css('opacity',0.92).slideDown();
}
​

Categories