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();
				});
			}
		});
	});
});

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.

Thanks, it worked perfectly!

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

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.