...

View Full Version : How to put and call this function?



Juo
11-10-2009, 09:06 PM
Hi guys ive got the following code


<html>
<head>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("form").submit(function() {
$.ajax({
type: "GET",
url: "release.php",
data: "name=Caspa&Rusko",
dataType: "xml",
success: function(xml) {
$(xml).find('release-list').each(function() {
$("span").text($(this).find("title").text()).show();
});
}
});
});
});
</script>

</head>
<body>
<p>Type 'correct' to validate.</p>
<form action="javascript:alert('success!');">
<div>
<input type="text" id="title" />
<input type="submit" />
</div>
</form>
<span></span>
</body>
</html>

Id like to perform the following script but without


<form action="javascript:alert('success!');">

So I thought id need to be everything in a function then call it with


<form action="javascript:functionName();">

Id also like to take the paramaters from <input type="text" id="title" /> and put the in data: "name=Caspa&Rusko", something like


data: "name= + name"

where would I set var name = $("search").val();

Finally if anyone could tell me where the AJAX magic goes so I can have a little loading spinner, that would amazing. Thanks :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum