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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:55:49+00:00 2026-05-14T01:55:49+00:00

(hello dr.Nick) :) So I posted a question yesterday about a content loader plugin

  • 0

(hello dr.Nick) 🙂 So I posted a question yesterday about a content loader plugin for jQuery I thought I’d use, but didn’t get it to work.

jQuery – Could use a little help with a content loader

Although it works now, I see some disadvantages to it. It requires heaploads of files where the content is in. Since the code essentially picks up the url in the href link and searches that file for a div called #content

What I would really like to do is to collect all of these files into a single file and give each div/container it’s unique ID and just pick up the content from those. So i won’t need so many separate files laying around.

Nick Craver thought I should use $.get()instead since it’s got a descent callback. But I’m not that strong in js at all.. And I don’t even know what this means. I’m basically used to Visual Basic and passing of arguments, storing in txt files etc. Which is really not suitable for this purpose.

So what’s the “normal” way of doing things like this? I’m pretty sure I’m not the only one who’s thought of this right? I basically want to get content from a single php file that contains alot of divs with unique IDs. And without much hassle, fade out the existing content in my main page, pick up the contents from the other file and fade it into my main page.

  • 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-14T01:55:50+00:00Added an answer on May 14, 2026 at 1:55 am

    Try this little self-contained example

    <?php
    if ( isset($_POST['contentId']) ) {
      // a contentId parameter has been sent
      // "we" know these ids:
      $contents = array(
        'a'=>'Mary had a little lamb',
        'b'=>'whose fleece was white as snow',
        'c'=>'And everywhere that Mary went',
        'd'=>'the lamb was sure to go'
      );
      // if we know the contentId
      if ( isset($contents[$_POST['contentId']]) ) {
        // send back the data associated with the contentId
        echo $contents[$_POST['contentId']];
      }
      else {
        echo 'unknown contentID';
      }
      die;
    }
    
    // if no contentId parameter has been sent at all, send the html document
    ?>
    <html>
      <head>
        <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
        <script type="text/javascript">
          function foo(contentID) {
            $('#container').hide('fast', function() {
              $('#container').load('?', {'contentId':contentID}, function() {
                $('#container').show('normal');
              });
            });    
          }
        </script>
      </head>
      <body>
        <fieldset>
          <button onclick="foo('a')">load content A</button>
          <button onclick="foo('b')">load content B</button>
          <button onclick="foo('c')">load content C</button>
          <button onclick="foo('d')">load content D</button>
         </fieldset>
        <div id="container">Hello.</div>
      </body>
    </html>
    

    The “important” part is that it passes the object {'contentId':contentID} to .load(), i.e. the request will contain a (post) parameter contentId=something. The php part of the script tests whether such a parameter is set or not using isset(). If there is, it tests whether it is has data associated with this contentId. The example uses a (static) array for this but it could be just anything.

    This has some drawbacks. E.g. the browser doesn’t cache the contents. Every time a button is hit data has to be sent forth and back between the server and the client. But you could use something like mod\rewrite or similar to let your php script react on urls like http://someserver/getContents/contentIdA , http://someserver/getContents/contentIdB, http://someserver/getContents/contentIdC and so on.

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

Sidebar

Related Questions

Hello I have been using JQuery for quite a while. I need to get
Hello i want to get simple list fragment example i have searched out but
Hello! I've been programming for a long time but just started developing for android,
Hello all I am working on javascript jquery and svg.I want to ask a
Hello I have like this 2 tables class User public int UserId{get;set;} { ....
hello friends i am trying to get a list of user id and want
Hello and thank you in advance. I know this is total noob question, and
Hello fellow developers... just to make sure, I want to ask this question: How
I am trying to take a string like Hello my name is Nick and
Hello wonderful stackoverflowers! I hope this question is within the scope of this site.

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.