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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:13:05+00:00 2026-05-20T10:13:05+00:00

Can jquery.ajax post a value from an attribute Name? If can, I want send

  • 0

Can jquery.ajax post a value from an attribute Name? If can, I want send image’s title apple to b.php, then return the data This is an apple from b.php to the div#result, Thanks.

a.php

<html>
<head>
</head>
<script src="jquery-1.4.4.min.js" type="text/javascript"></script> 
<script language="javascript"> 
$(document).ready(function () {      
var params = "value=" + $('#send').attr(title);  
$.ajax({        
     url:'b.php',        
     type:'post',                 
     dataType:'html',            
     data:params,                
     success:data     
     }); 
function data (html) {     
$("#result").html(html);  
} 
}); 
</script> 
<body> 
<div id="result"></div>
<img id="send" src="apple.jpg" title="apple" />
</body>
</html>

b.php

<?php
echo 'This is an '.$_REQUEST['value'].'.'; 
?> 
  • 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-20T10:13:05+00:00Added an answer on May 20, 2026 at 10:13 am

    If you put quotes around the attribute name, .attr('title'), it should work. Otherwise, title will be treated as variable, and, as it is not defined, it will have the value undefined.

    But better is to pass an object to data and let jQuery take care of proper encoding:

    $.ajax({        
        url:'b.php',        
        type:'post',                 
        dataType:'text', // actually, you are not outputting HTML
        data: {value: $('#send').attr('title')},                
        success:data     
    }); 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Jquery AJAX to get a value from a PHP script. This line works
How can I return the value pinNumber from jquery ajax so I can append
I can successfully post an array to PHP using Ajax Post but I want
Hi i want to get changed text value from JQuery but i can't select
if so can show simple example, ex in jquery ajax.post
I'm using Jquery, Ajax and PHP to try and send a variable to be
just been trying to recieve the session value from multiple jquery ajax requests on
i have a problem when it comes to retrieving value from jQuery to php.i
I want to user jquery ajax calls, for example; function addnewteacher(){ $.ajax({ type: POST,
I'm using jquery to get value from a select box so I can than

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.