the lopading graphic to show.
MY code is below, can anyone help?
<html>
<head>
<script type="text/javascript" src="autocomplete/scripts/
jquery-1.2.6.min.js"></script>
<script type="text/javascript">
function register(){
$.ajax({
type: "POST",
url: "test.cfm",
data: "w00t=" + document.getElementById("name").value,
success: function(html){
$("#response").html(html);
}
});
$.ajaxStart(function(){
$('#loading').show();
});
$.ajaxStop(function(){
$('#loading').hide();
});
}
</script>
</head>
<body>
<form action="" method="post">
<label for="name">Name:</label><br />
<input type="text" name="username" id="name" size="25" />
<input type="button" name="submit" id="submit" value="Subscribe"
onclick="register()"/>
</form>
<div id="response">
<!-- Our message will be echoed out here -->
</div>
<div id="loading" >loading</div>
</body>
</html>
On Sep 29, 11:15 am, mattastic <mharris...@yahoo.co.uk> wrote:
> Thanks very much for your replies.
>
> Could you please post the whole page code?
>
> So I can see how the javascript, html and ajax works together
>
> I'mn struggling to understand how the whole page is layed out.
>
> Thanks in advance
>
> On Sep 28, 2:18 pm, Mark Gorman <dayg...@gmail.com> wrote:
>
> >http://docs.jquery.com/Ajaxhaseverything you need but a simple
> > example would be...
>
> > $(document).ready(function(){
> > $.ajaxStart(function(){
> > $('.loading').show();});
>
> > $.ajaxStop(function(){
> > $('.loading').hide();});
>
> > //i have trouble with the post permiters so i always do it the {} way
> > but you can just pass a array
> > $.post('example.php',{peram1 : 'hello',peram2 : 'world', myval : $
> > ('.myinput').val()},function(data){
> > alert($(data).find('result').text());
>
> > });
> > });
>
> > if the return was xml ie <message><result>it saved</result></message>
> > then you would get it saved in a alert watch some of the functions
> > though if you tell it to expect something as it will just
> > brake. .loading i am useing as your loading graphic or a div
> > containing it etc using css to absolutely position it or putting it
> > wherever you want it. you can do better things if you want but if you
> > just trying things for the first time this will do :P
>
> > On Sep 28, 10:58 am, mattastic <mharris...@yahoo.co.uk> wrote:
>
> > > Could soneone please show me an example of a simple ajax post to a
> > > coldfusion page, with a loading graphic?
>
> > > I cant find an appropriate example in the documentation.
>
> > > Thankyou
No comments:
Post a Comment