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 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

I am using Jquery AJAX to post a form on my page. I want
Can you tell me examples for jquery with ajax? Can I combine an UpdatePanel
Using the jQuery Validation plugin and AJAX, how can I validate the contents of
I am getting an error in an ajax call from jQuery. Here is my
I have a via with some jQuery function to get value from HTML element
Can jQuery be extended so that I can use the above syntax? I can't
Can jQuery test an array for the presence of an object (either as part
In jQuery you can get the top position relative to the parent as a
How can I use jquery to remove a SPECIFIC div that has no children
I know that jQuery.extend can be used to add by own custom methods to

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.