Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1096175
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T00:14:34+00:00 2026-05-17T00:14:34+00:00

I’m using the ‘timepickr’ jQuery function, the problem is it works ok in the

  • 0

I’m using the ‘timepickr’ jQuery function, the problem is it works ok in the main webpage, however when I invoke it through an AJAX call, the funcionality is non-existant. The input box is displayed fine, but the mouseover funcionality isn’t there. Code I’m using as follows….

This is the page that contains the “div2” div: Note, the invocation of the timepickr jQuery thing works fine.

<head>
<link rel="Stylesheet" media="screen" href="reset.css" /> 
<link rel="Stylesheet" media="screen" href="styles.css" /> 
<link rel="Stylesheet" media="screen" href="ui.core.css" /> 
<link rel="Stylesheet" media="screen" href="ui.timepickr.css" /> 
<link rel="stylesheet" media="screen" href="jquery.timepickr.css" type="text/css" /> 
<SCRIPT LANGUAGE="JavaScript" SRC="js/timepicker.js"></SCRIPT> 
<script type="text/javascript" src="js/jquery.js"></script> 
<script type="text/javascript" src="js/showDiv2Contents.js"></script> 
<script type="text/javascript" src="js/jquery.ui.all.js"></script> 
<script type="text/javascript" src="js/jquery.timepickr.js"></script> 
<script type="text/javascript"> 
$(document).ready(function() {
    $(".timepickr").each(function(){
        $(this).timepickr();
    })
});
</script> 
</head>
<body>
<div id="div1">
<input class='timepickr' type='text' value='09:00' /><br>  <!-- This works fine -->
</div>
<select onchange="showDiv2Contents(this.value)"> 
<option value='0' selected>1</option> 
<option value='1'>2</option>
</select>
<div id="div2"></div>
</body>

When the dropdown box’s state is changed, the showDiv2Contents js function is called, as follows:

function showDiv2Contents()
{
    if (window.XMLHttpRequest)
    {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        xmlhttp=new XMLHttpRequest();
    }
    else
    {
        // code for IE6, IE5
        xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
    xmlhttp.onreadystatechange=function()
    {
        if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
            document.getElementById("div2").innerHTML=xmlhttp.responseText;
        }
    }
    xmlhttp.open("GET","testajax2.php",true);
    xmlhttp.send();
}

…and the “testajax2.php” is as follows…

<?php
echo "<br><br><br>";
echo "Contents of Div2:";
echo "<br><br><br>";
echo "<input class='timepickr' type='text' value='09:00'/>"; //This doesn't work
?>

While the contents of testajax2.php is displayed fine, the timepickr functionality is non-existant. Any ideas? Thanks so much in advance,

Mike

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T00:14:35+00:00Added an answer on May 17, 2026 at 12:14 am

    If you’re already including jQuery I’d take advantage of it for the AJAX call as well, and use a success callback to apply the timepicker to new elements in the loaded <div> as well. To do all of that, your function would be shortened down to:

    function showDiv2Contents()
    {
      $("#div2").load("testajax2.php", function() {
        $(this).find(".timepickr").timepickr();
      });
    }
    

    This uses .load() to get/load the ajax content of testajax2.php then executes the .timepckr() plugin again on .timepickr elements that were just created/loaded inside <div id="div2">.

    Currently the dynamically loaded elements simply aren’t there when the $(".timepickr") selector looks for results, so no code is run on them. As an aside, your document.ready code can also be trimmed down, there’s no need for the .each(), like this:

    $(function() {
      $(".timepickr").timepickr();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
We're building an app, our first using Rails 3, and we're having to build
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We are using XSLT to translate a RIXML file to XML. Our RIXML contains

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.