Jump to content

Java script ignoring a button


Shadowing

Recommended Posts

For some reason when I use ajax to place a button on a page. I cant get another java/ajax script to read that the button was pushed. Anyone have any obvious idea as to why? When i hit the button the screen refreshes so thats how i know the javascript isnt reading the button. I can read a input form that is placed on the page just not a button.

 

both scripts are like this one below.  one for putting the button on the page and a simliar one for clicking on the button.

 

$(document).ready(function() {        

$("#update_announcements").click(function(event) {          
	event.preventDefault();
	$.ajax({            

		url: "/System_Lords/ajax/announcements.php?functions=announcements_box",            

		type: 'POST',            

		dataType: 'json',            

		data: { 

			announcements: '<?php echo $announcements; ?>'         

			},            

			success: function(response) {              

				$('#announcements_box').html(response.announcements_box);
				$('#announcements_button2').html(response.announcements_button);

				}        

				});        

				});      

				});  

 

 

Link to comment
https://forums.phpfreaks.com/topic/259918-java-script-ignoring-a-button/
Share on other sites

Im starting to some what understand firebug now.

 

been sitting here trying alot of things and for some reason my java script still ignores this button.

 

whats crazy is i read the link you gave me and they talk about using "on" but yet i cant find a reference to "on" in any tutor sites i go too. Then someon told me to try using "live" there is only one change_announcements id on the page also.

 

also i tried $("input#change_announcements") the button is type"submit"

<input type='submit' name='change_announcements' id='change_announcements' value='Update2'>

 

	$("#change_announcements").live("click",function(){         
	event.preventDefault();
	$.ajax({ 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.