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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T06:21:16+00:00 2026-06-04T06:21:16+00:00

I’m trying to load div content based on the a href being clicked and

  • 0

I’m trying to load div content based on the a href being clicked and pass in a parameter. For example, Link 1
Clicking on Link 1 will pass value “3” to process.php, and return back the value “apple is good for you”.

However, I can’t seem to be able to pass the value without having a submit button. Anyway I can pass the parameter to another php file to process, and return the value?

$(document).ready(function(){
     $("#testing a").live("click", function(evt){
         var id= $(this).attr('id');
        $.post("process.php", { id: id },
        function(data) {
          alert(data);
                    $('#result').load(data);
        });
     })

});

Below is my HTML

<div id="testing">
<a href="" id="11"> hello </a>
</div>

<div id="result"></div>

Appreciate your help, thanks a lot!

  • 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-04T06:21:17+00:00Added an answer on June 4, 2026 at 6:21 am

    You shouldn’t be using numbers for id values. Instead, prefix them with a letter, or consider adding them to a data- atribute on the element.

    Additionally, $.live() is deprecated, and we are encouraged to use $.on() from here on out for event delegation. I’ve gone ahead and handled this in the code below, but the id issue remains.

    Lastly, $.load() and $.html() aren’t the same. If you want to load data into an element, you don’t call the load method (though the name could lead to that confusion).

    // Short-hand version of $(document).ready();
    $(function(){
      // Handle anchor clicks on #testing
      $("#testing").on("click", "a", function(e){
        // Prevent links from sending us away
        e.preventDefault();
        // POST our anchor ID to process.php, and handle the response
        $.post("process.php", { 'id': $(this).attr("id") }, function(data){
          // Set the response as the HTML content of #result
          $("#result").html(data);
        });
      });
    });
    

    From your process.php file, you might have something like the following:

    $msg = array( 
        "...chirp chirp...",
        "This is response number 1",
        "And I am the second guy you'll see!",
        "Apples are good for you!" 
    );
    
    $num = $_POST["id"] || 0;
    
    echo $msg[ $num ];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Configuring TinyMCE to allow for tags, based on a customer requirement. My config is
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
i got an object with contents of html markup in it, for example: string
I need a function that will clean a strings' special characters. I do NOT

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.