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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:28:13+00:00 2026-05-22T01:28:13+00:00

I tried to post values from the link title attribute with jquery ajax json

  • 0

I tried to post values from the link title attribute with jquery ajax json post. Here is my code. where is the problem? Why doesn’t it work?

main.php

<script type="text/javascript">     
    $(document).ready(function(){
        $(".link").click(function(){
        var aa = $(this).attr('title'); 
          $.ajax({
             url: "data.php", 
             dataType: "json", 
               data: "number1="+aa, 
             success: function(json){ 
                $("#result").html(json.number1); 
             }
          });
        });
    });
    </script>
      <a href="#" class="link" title="apple">A</a>
      <a href="#" class="link" title="banana">B</a>
      <a href="#" class="link" title="orange">O</a>
        <div id="result"></div>

data.php

<?php
$number1 = $_GET['number1'];
echo json_encode($number1);
?>
  • 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-22T01:28:13+00:00Added an answer on May 22, 2026 at 1:28 am

    Try this:

    <script type="text/javascript">     
        $(document).ready(function(){
            $(".link").click(function(){
            var aa = $(this).attr('title'); 
              $.ajax({
                 url: "data.php", 
                 dataType: "json", 
                   data: {"number1": aa}, 
                 success: function(json){ 
                    $("#result").html(json.number1); 
                 }
              });
            });
        });
        </script>
          <a href="#" class="link" title="apple">A</a>
          <a href="#" class="link" title="banana">B</a>
          <a href="#" class="link" title="orange">O</a>
            <div id="result"></div>
    
    
    <?php
    $number1 = $_GET['number1'];
    echo json_encode(array('number1' =>$number1));
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following JSON structure, being returned from an AJAX call (pseudo values)
I've tried to move WCF to NetDataContractSerializer using the code in this post: http://lunaverse.wordpress.com/2007/05/09/remoting-using-wcf-and-nhibernate
I tried to insert multiple rows from one form using checkboxes, include take values
I have tried solving this problem by posting other related questions here that focused
Following on from a previous question, ( previous question here ), the problem I'm
I want to do the jQuery POST every 5 seconds with different POST values
i tried to find any helpful post for my problem, but didn't find so
I got the sample code from Facebook to post a message. At first it
I have problem with fb sdk for Android (downloaded from http://github.com/facebook/facebook-android-sdk ). Tried to
I'm using JQuery to get city data from geonames. My problem is when I

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.