Jump to content

Ajax function only works once


trums

Recommended Posts

In this function I am attempting to grab the value of one of three radio buttons onclick. Then a lightbox is opened, inviting the user to add more information with a submit button. This works great until after you have gone through the process once. If you try to go through the process and 2nd time and click one of the radio buttons again, the submit button doesn't work! What can I do to make it work every time? The complete function is below:

 

#rvspNoteSave is the submit button and I used the Boxy lightbox: http://onehackoranother.com/projects/jquery/boxy/

 

$("#rvspForm input:radio").click(function(){
	var the_value = $(this).val();
			new Boxy('<div style="margin:5px;">Leave an rsvp note<br/><textarea id="rvspNote"></textarea><br/><div class="span-4"></div><div class="span-4 last"><a href="#" id="noteClose">No, Thanks</a> <input type="button" id="rvspNoteSave" value="Save"/></div><hr class="space"/></div>', {title: "Add A Note", closeable: true, afterShow: function() {
				$("#rvspNoteSave").click(function(){
					Boxy.get(this).hide();
				});
			}, afterHide: function() {
				$.ajax({  
					type: "POST",
					url: "http://localhost/events/ajax_savervsp/",
					data: "eventId="+eventId+"&note="+$("#rvspNote").val()+"&rvsp="+the_value,
					beforeSend:function() {
						$("#yourrvsp").html("<center><img src='http://p3.localhost:81/static/images/loader.gif'></center>");
					},
					success: function(data) { 
						$("#yourrvsp").html("<center><br/><b>Your RVSP:</b> "+data+"</center>").show();
					},
					error: function() {
						alert("Connection to server interrupted. Please try again.");
						$("#yourrvsp").html("");
					}
				}); 

			}});
});

 

Your help is greatly appreciated.

Link to comment
Share on other sites

The submit button is just a normal submit button activation. The #rvspNoteSave in the above code is the code that the submit button activates. All it does is close the lightbox.

 

I use firefox, but I will install firebug and see what it gives me.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.