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

  • SEARCH
  • Home
  • 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 7901683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:17:19+00:00 2026-06-03T09:17:19+00:00

I have a problem with an accordion not working when receiving contents from another

  • 0

I have a problem with an accordion not working when receiving contents from another page via AJAX. THe page is this one: http://jbm.utad.pt/testes/tempo/index.php

As soon as the page loads it sends a default city name to processtempo.php which with AJAX shoots the results back to a div:

In the processtempo.php I have the HTML for an accordion but the jQuery for it is in index.php. Is this accordion not working because the HTML have to be in the main page or did I screw up with the jQuery?

You can view the accordion jQuery script in the source… I haven’t yet put it in specific js file.

Thanks so much for all the help possible and sorry for this vague question

Cheers

  • 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-06-03T09:17:21+00:00Added an answer on June 3, 2026 at 9:17 am

    You are assigning a click() event to .tempo-head, and doing a bunch of other things to elements before they are loaded onto the page by the ajax routine.

    You’ll need to get the latest version of JQuery for the following to work. I noticed that you have an outdated version currently (1.4.2)

    Try changing this:

    $('.tempo-head').click(function () {
    

    to

    $('#sidebar').on('click', '.tempo-head').click(function () {
    

    OR

    Move all your accordion routines to inside the success callback in your ajax call like below.

    $(document).ready(function(){
    
        var cidade2='penafiel';
        var dataString = 'cidade='+ cidade2;
        $.ajax({ type: "POST", url: "processtempo.php", data: dataString, cache: false,
            success: function(html){
                $("#exibe_tempo").html(html);
            }
        });
    
        $(".cidade").change(function(){
            var cidade=$(this).val();
            var dataString = 'cidade='+ cidade;
    
            $.ajax({ type: "POST", url: "processtempo.php", data: dataString, cache: false,
                success: function(html){
                    $("#exibe_tempo").html(html);
    
                    //Add Inactive Class To All Accordion Headers
                    $('.tempo-head').toggleClass('head-off');
    
                    //Set The Accordion Content Width
                    var contentwidth = $('.tempo-head').width();
                    $('.tempo-cont').css({'width' : contentwidth });
    
                    //Open The First Accordion Section When Page Loads
                    //$('.tempo-head').first().toggleClass('head-on').toggleClass('head-off');
                    //$('.tempo-cont').first().slideDown().toggleClass('tempo-cont');
    
                    // The Accordion Effect
                    $('.tempo-head').click(function () {        
                            if($(this).is('.head-off')) {
                                $('.head-on').toggleClass('head-on').toggleClass('head-off').next().slideToggle().toggleClass('tempo-cont');
                                $(this).toggleClass('head-on').toggleClass('head-off');
                                $(this).next().slideToggle().toggleClass('tempo-cont');
                            }
    
                            else {
                                    $(this).toggleClass('head-on').toggleClass('head-off');
                                    $(this).next().slideToggle().toggleClass('tempo-cont');
                            }
    
                    });
    
    
                }
            });
        });
    
    
        return false;
    
    }); // END DOC READY
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is one of the problem i have been working from a long time.This
I have a problem styling/templating an AccordionItem in the accordion control from the silverlight
I have a jQuery accordion from this site and edited for my purposes, but
Ok an have an accordion, but i am not using jQuery UI. This is
I have an Accordion control to which I have added a datagrid. The problem
I have problem creating new instance of excel 2007 using VBA (from Access 2002).
Got a problem with an accordion script, the accordion worked when I was working
I seem to have a strange problem. I am working on a simple dashboard
I have an ASP.NET WebForms control (derived from Control, not WebControl, if it helps)
I have some problem with my form. i want to use jquery ajax to

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.