# Beginner Ajax question - getting value from href

**URL:** https://forum.kirupa.com/t/beginner-ajax-question-getting-value-from-href/309833
**Category:** programming
**Created:** [May 25, 2010, 8:28pm UTC](https://forum.kirupa.com/t/beginner-ajax-question-getting-value-from-href/309833 "2010-05-25T20:28:09Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![omgnoseat](https://avatars.discourse-cdn.com/v4/letter/o/5fc32e/32.png) [@omgnoseat](https://forum.kirupa.com/u/omgnoseat)
#### Post date: [May 25, 2010, 8:28pm UTC](https://forum.kirupa.com/t/beginner-ajax-question-getting-value-from-href/309833/1 "2010-05-25T20:28:09Z")

</div>

Hello,

I’ve been fiddling around with ajax, I have little experience with htmlish languages so it takes some time to get into. I have followed some tutorials on w3schools and they have been very helpfull. There is just one problem, they all use form components to send info to javascript.

What I want to know is how to use href links to send information.  
I have the following situation:

- Data is loaded from a database, for each item from the database a href link is generated.
- The ID from the item is stored in the href

```auto

<script type="text/javascript">
	
	function showData(ID){
		
	      //use ajax to send the variable to a php file which retrieves the corresponding data for the given ID
	}

</script>

<?php

include("connect.php");

	$query = "SELECT * from nieuws ORDER BY datum DESC";
	$result = mysql_query($query);
	
	//terwijl er resultate blijven zijn, echo de resultaten
	while($row = mysql_fetch_array($result)){

		
		?><a href = "javascript:showData('<?php echo ''.$row['titel'].'' ?>' )" > <?php echo ''.$row['titel'].'' ?> </a>
	<?php
	} //end of while
	

?>

```

My solution is to make the link a javascript function which will take care of the ajax, but this doesn’t seem like an appropiate solution.

Any suggestions?  
Thanks in advance
