0

Hi,

I'm very new to Javascript and AJAX so I'm using a script that I found, and I need it to send a PHP variable from the global variable (in the address bar where it says &post=94 for example) along with the other data that the script sends to a php script.

I've tried to add what I think should work but it clearly doesn't and I have no clue as how the variable would be used once it fetches the $_GET (if that is even allowed?).

Any help would be much appreciated, thanks!

The script looks like this:

$(document).ready(function() {
	$('a.delete').click(function(e) {
		e.preventDefault();
		var parent = $(this).parent();
[B]		var postID = $_GET['postID'];[/B]

		$.ajax({
			type: 'post',
			url: 'remove_row.php',
			data: 'ajax=1&delete=' + parent.attr('id').replace('record-','') + '&post=' +[B] postID[/B],
			beforeSend: function() {
				parent.animate({'backgroundColor':'#fb6c6c'},300);
			},
			success: function() {
				parent.slideUp(300,function() {
					parent.remove();
				});
			}
		});
	});
});
3
Contributors
3
Replies
5
Views
7 Years
Discussion Span
Last Post by prerna21
1

If the javascript is already on a PHP page then you can just do

var postID = <?php echo $_GET['postID']; ?>

And keep the rest of your code the same.

0

i want to do the same thing but send the javascript variable to jsp page using post method.and save the data in data page without reloading

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.