Ajax data not received in PHP Script


I am using this JQuery/Ajax script to post some data to the server:

		var data = {
			page_num: "test"

			type: "POST",
			url: "data.php",
			data: data,
			success: function(res) {

However, nothing is received on the PHP end:

if (isset($_POST["page_num"])) {      // <- this condition is always false
	$requested_page = $_POST['page_num'];

I can output text in my PHP script and this will show in the HTML file, but I cannot post any data.

Even this simple script does not work. But as soon as I use GET instead of POST, it works.

				url: "data.php",
				type: "POST",
				data: {
					name: "Donald Duck",
					city: "Duckburg"
				success: function(result) {

If you inspect the AJAX call with something like firebug or chrome developer tools, do you see the POST data there?

Yes. I can see it in Firefox/Firebug.

Then PHP should get it, unless something is preventing it.
Do you have a .htaccess file with this project? If so, could you please post it here in full?
My guess is that something is redirecting the request so it becomes a GET request and you lose the POST data in the process.

Is it the same page? Maybe it’s a snyc or reload not firing a load event thing?

Isn’t it possible that this is giving me problems:
“Due to browser security restrictions, most “Ajax” requests are subject to the same origin policy; the request can not successfully retrieve data from a different domain, subdomain, or protocol.”

I am testing this on my local computer, so everything is on localhost.

No that shouldn’t be a problem.