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 6000139
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:39:03+00:00 2026-05-23T00:39:03+00:00

I have a XMLhttpRequest when I get the response I want to bind a

  • 0

I have a XMLhttpRequest when I get the response I want to bind a div that uses jQuery for some animation (tabs), but when I get the response the display the tabs, then the jQuery doesn’t work, but if I transfer the block (div) that uses jQuery outside the position that uses Ajax, then it works fine ….

function searchLocations()
{
    var xmlhttp;
    var x, xx, txt;

    var search_text = document.getElementById("txtSearch").value;

    if(search_text != "")
    {
        if(window.XMLHttpRequest)
            xmlhttp = new XMLHttpRequest();
        else
            xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

        xmlhttp.onreadystatechange = function()
        {
             if(xmlhttp.readyState == 1)
                 document.getElementById("search_locations_result").innerHTML="<p align='center' ><img src='account/images/working.gif'></p>";

             else if (xmlhttp.readyState == 4 && xmlhttp.status == 200)
             {
                document.getElementById("status").innerHTML="";
                //document.getElementById("txtSearch").value="";
                x=xmlhttp.responseXML.documentElement.getElementsByTagName("Result");   
                txt="<table border='0' width='100%'>";

                for (i = 0; i < x.length; i++)
                {
                    txt = txt + "<div class=\"d"+id2+"\" style=\"display:none\">"+
"<div id='adv' class='usual'> "+
  "<ul>"+
    "<li><a href='#t13'>Tab 1</a></li> "+
    "<li><a href='#t23' class='selected'>Tab 2</a></li> "+
   " <li><a href='#t33'>Tab 3</a></li> "+
  "</ul> "+
  "<div id='t13' style='display: none; '>This is tab 1.</div> "+
  "<div id='t23' style='display: block; '>More content in tab 2.</div>" +
 " <div id='t33' style='display: none; '>Tab 3 is always last!</div> "+
"</div> "+

        "</div>";

        }// end for

                document.getElementById("search_locations_result").innerHTML=txt;               
             }
            }
        xmlhttp.open("GET","ajax_search_locations.php?name="+search_text+"&page="+page,true);
        xmlhttp.send();
        }
        else
            document.getElementById("status").innerHTML="";

    }

Where div usual is that uses jQuery like this :

$(document).ready(function() {
    $("div.usual ul").idTabs();
});
  • 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-23T00:39:04+00:00Added an answer on May 23, 2026 at 12:39 am

    this is a jQuery ajax call.
    I’ve simplified the whole thing:

    $.ajax({
        type: 'GET',
        url: 'ajax_search_locations.php',
        data: { name: $('txtSearch').val(),  page: page },
        dataType: 'json',
        complete: function(XMLHttpRequest, textStatus) {
        if (XMLHttpRequest.status === 200)
        {
    
        var txt= "<div class=\"d"+id2+"\" style=\"display:none\">"+
            "<div id='adv' class='usual'> "+
            "<ul>"+
             "<li><a href='#t13'>Tab 1</a></li> "+
             "<li><a href='#t23' class='selected'>Tab 2</a></li> "+
            " <li><a href='#t33'>Tab 3</a></li> "+
            "</ul> "+
            "<div id='t13' style='display: none; '>This is tab 1.</div> "+
            "<div id='t23' style='display: block; '>More content in tab 2.</div>" +
            " <div id='t33' style='display: none; '>Tab 3 is always last!</div> "+
            "</div> "+
            "</div>";
    
        $('#search_locations_result').html(txt);
        }
        }
    });
    

    I guess you have to understand how jQuery selectors work, before.

    PS: server’s response will be a JSON, as I’ve specified in the dataType.

    If your dataType is XML then you have to change your call like this

    dataType: "xml",
    

    Your XMLHttpRequest.responseText should contain your XML and you will parse it with something like this:

    $(XMLHttpRequest.responseText).find("<your XML tag>").each(function()
      {
        // $(this).attr("<your XML attribute>");
      });
    

    You can find a detailed explanation here and here.

    Hope it helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web application that adds contextual information to XmlHttpRequest objects using the
I have a javascript that does this (http is your XMLHttpRequest object) var r
Don't know how to explain it better but i'm trying to get a response
Straight to the point: I have this javascript: for(item=1;item<5;item++) { xmlhttp=new XMLHttpRequest(); xmlhttp.open(GET,'zzz.php', true);
I am writing some functionality using jQuery that i normally handle with a page
I have found the following piece of code which uses XmlHttpRequest to read JSON
I have a bookmarklet that when clicked opens up a div popup on their
I have a JSP page that queries a MySQL database, I want to send
I have a PHP script (fetchData.php) that fetches some data and outputs it to
I've got a problem with XMLHttpRequest. I have a that has a onChange event

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.