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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T04:30:31+00:00 2026-06-14T04:30:31+00:00

I had to ask this one again, sorry. So I am running this jQuery

  • 0

I had to ask this one again, sorry. So I am running this jQuery to slide toggle a span in my PHP loops output. I have some PHP that generates some calls to the db to get more detailed information back for each item.

I know so far I have got it making the call to the PHP script. I can see the packets returning with the HTML echoed from the PHP file. but I’m having difficulty getting jQuery to insert the returned data into the specified span.

This is a simplified version of what the loop items look like:

<span class="searchitem">

 <span style="visibility:hidden;" class="name">some name</span>

 <span class="btn">Details</span>

 <span class="itemdetails" style="display: none;">
   //hidden area to populate with returned ajax html from php script 
 </span>

</span>


<span class="searchitem">

 <span style="visibility:hidden;" class="name">another name</span>

 <span class="btn">Details</span>

 <span class="itemdetails">
   <div>
     <p>
     this is the area i need the html to populate
     </p>
   </div>
</span>

</span>.................

This is the jQuery that I’m trying to run. I know everything works up to success. I can’t get the data from there.

<script type="text/javascript">   
      var ajax_load = "<img src='images/loading.gif' style='width:50px;' alt='loading...' />"; 
      var loadUrl = "ajax/item_details.php";
      $(document).ready(function ()
              {
                    $('.searchitem').each(function () {

                    var itemname = $(this).find('.name').text();
                    var ename = encodeURI(itemname);
                    var requestUrl = loadUrl + ename;
                        $(this).find('.itemdetails').hide();
                        $(this).find('.btn').click(function ()
                        {
                            var returned = "";
                                $.ajax({
                                type: "GET",
                                url: loadUrl,
                                data: "name=" + ename,
                                dataType: "text",
                                error: function () { alert("error") },
                                success: function (data) { $(".ptavail").append(data); alert("successful") }
                                }); 
                    $(this).parent().find('.ptavail').html(ajax_load).slideToggle(1500).html(returned);
                        });
                    });
              });
</script>

As you can see from the code I’m trying to get the click function the set everything off. I know the PHP file is receiving the call and returning the data but I’m stuck trying to get the jQuery to fill the .itemdetails with the returned data.

What is wrong with this? Would I need to put the AJAX into a separate function for it to behave like I need, or do I need to make it synchronous for it to work? I’m trying to basically replace everything between .itemdetails spans with first a loading symbol and then the data returned with AJAX…. As it is now I get error alert so there’s something wrong with the ajax call I know it does the request properly and the PHP returns the results but getting AJAX to read them is proving problematic.

I can see that the content type in the headers is text, so how do I get the AJAX to do the call properly?

  • 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-14T04:30:32+00:00Added an answer on June 14, 2026 at 4:30 am

    Put $(this).parent().find('.itemdetails').html(ajax_load).slideToggle(1500).html(data);

    inside the “success” part of the Ajax request.

    success: function(data) {
      $(this).parent().find('.itemdetails').html(ajax_load).slideToggle(1500).html(data);
    }
    

    The success function is there to say “when the Ajax has worked, do this”

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

Sidebar

Related Questions

I've had to ask this one again, sorry, but I'm having a problem trying
I have had a few problems getting this right, so I wanted to ask
It's a basic question.. but had to ask. For a program like this, if
So I had an app running Phonegap 1.4.0 (don't ask), I decided to upgrade
Sorry if I ask silly question, but so far had no luck in figuring
Sorry to have to ask yet another position:fixed related question, but reading through various
I'm quite ashamed to ask a question like this one, but I've been trying
Basic question.. had to ask. Any help will be appreciated. Q: Why can't I
Had a good read through similar topics but I can't quite a) find one
Had a problem with the recursive conflictCheck() method. That seems fine now. I have

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.