Solved

How to add div.slideUp to my current Ajax/jQuery?

Posted on 2015-02-16
2
250 Views
Last Modified: 2015-03-04
Hi,

I got this jQuery/Ajax:

<script>

	$(document).ready(function() {
		$('#mount_tube_button').click(function(){
			$.ajax({
			
				url: 'conf_overview_handler.php',
				type: 'post',
				data: {'<?php echo $input_name; ?>':$('input[name=<?php echo $input_name; ?>]:checked').val()},
				success: function(msg){
					$('#mount_<?php echo $location; ?>_AJAX').html(msg);
				}
			
			}); // Ajax call
		}); //event handler
	}); //document.ready

</script>

Open in new window


How can I add this to it:
$( "#toggle_rod" ).slideUp( "slow" );

Open in new window


I have tried this, but it does not work:
<script>

	$(document).ready(function() {
		$('#mount_tube_button').click(function(){
			$.ajax({
			
				url: 'conf_overview_handler.php',
				type: 'post',
				data: {'<?php echo $input_name; ?>':$('input[name=<?php echo $input_name; ?>]:checked').val()},
				success: function(msg){
					$('#mount_<?php echo $location; ?>_AJAX').html(msg);
					$( "#toggle_rod" ).slideUp( "slow" );
				}
			
			}); // Ajax call
		}); //event handler
	}); //document.ready

</script>

Open in new window

0
Comment
Question by:kgp43
  • 2
2 Comments
 
LVL 11

Expert Comment

by:N R
ID: 40612282
Should the slide only happen on the ajax success or should it slide on click?
0
 
LVL 11

Accepted Solution

by:
N R earned 500 total points
ID: 40612297
http://jsfiddle.net/t4rzo8t7/

This shows the slide up command working when outside the success.  I imagine your ajax request is not succeeding and that may be why your slide up event isn't firing.  Keep in mind in my example I removed your php variables.

	$(document).ready(function() {
		$('#mount_tube_button').click(function(){
			$.ajax({
			
				url: 'conf_overview_handler.php',
				type: 'post',
				data: {'':$('input[name=]:checked').val()},
				success: function(msg){
					$('#mount__AJAX').html(msg);
				}
			
			}); // Ajax call
            $( "#toggle_rod" ).slideUp( "slow" );
		}); //event handler
	}); //document.ready

Open in new window

0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

831 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question