Thanks for the replies ive had a bit of play with the jquery api and have got a bit further. Ive managed to remove my original ajax script and work it in to the jquery function although i still have a way to go.
this is a simple page just to get everything working. When a link is clicked it returns the ajax data. This bit works fine except i can't change the variables that iam sending to the query page.
Code:
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<script src="../jquery.js" type="text/javascript"></script>
<script src="ajax.js" type="text/javascript"></script>
</head>
<body>
<a href="?age=perch#" onclick="ajaxFunction()" id="age" rel="perch">click me for perch</a>
<a href="?age=cod#" onclick="ajaxFunction()" id="age" rel="cod">click me for cod</a>
<div id="ajaxDiv">
test should appear here
</div>
</body>
</html>
this is the function iam trying to write
Code:
function ajaxFunction(){
var age = document.getElementById('age').rel;
$.get("../seaandme_query.php", { sex: "com", age: age },
function(data){
var ajaxDisplay = document.getElementById('ajaxDiv');
ajaxDisplay.innerHTML = data;
});
}
It works but its looking for the id by element and iam assuming is always finding the first id and using the rel="" value so its not changing when i click the second link, just returns the same data.
How do i pass a unique value to the function? is there a way of using variables from a link eg href="?age=tuna#
heres the test page iam working on http://www.mcsuk.org/seaandme/ajax/ajax.php
thanks for your help
Bookmarks