$_POST is empty via Ajax

I am sending data using $.ajax and using the POST method. I cannot use GET because the data is long in the MB range. But on the receiving php script, it always seems that the $_POST is empty. This is not the case with I run my app in the browser with my localhost XAMPP.

I thought that it could probably be because of some PHP.INI settings. All I found was always_populate_raw_post_data and turned that On. But still doesn’t work. Any ideas?

Hmm… did you var_dump($_POST) on your PHP page?
If the data is too big, maybe PHP timed out… try to put set_time_limit(0); on the first line of your PHP page (so it will never time out) and make sure upload_max_filesize (for input with type as “file”) and post_max_size are set properly in your php.ini file with the size of your posted data

Keep me updated :slight_smile:
BTW it will be great if you can show us some codes.

Good luck

OK, here’s what I found out. Normal POST with a form works, but POST via Ajax doesn’t.

Here’s my code that sends that Ajax.

<!DOCTYPE html>
<html>
    <head>
        <title>Ajax Progress</title>
        <script src="js/jquery.js"></script>        
        <script src="js/jquery.ajax-progress.js"></script>
        <script>
            $(function() {		
				$.ajax({
					type: 'POST',
					url: 'post.php',
					dataType: 'text',
					data: {
						input1: "asofjdsl;jgfialsjf",
						input2: "asofjdsl;jgfialsjf",
						input3: "asofjdsl;jgfialsjf",
						input4: "asofjdsl;jgfialsjf",
						input5: "asofjdsl;jgfialsjf",
						input6: "asofjdsl;jgfialsjf",
					}
				}).done(function(data){
					alert(data);
				});
            });
        </script>
    </head>
    <body>
	testing Ajax Post
    </body>
</html>  

And here’s my receiving PHP code

<?php var_dump($_POST); ?>

By the way, I have all my php.ini settings correct I believe.

memory_limit = 128M
post_max_size = 100M

And I don’t think it’s because of timeout because this is data sent from local to local. Even a short data set failed.

My further testing, I found out that the server always treat the Ajax POST as GET instead. I sent back phpinfo() this time and the receiving Javascript simply document.write(data) and there’s not POST information.

Oh ok sorry I though it was a couple of megabytes of data haha…

I tried on my side, in a browser, it’s working, but inside EXEOutput, the only way I found is using the GET method… :frowning:

Maybe wait for the GDG admin or someone else to check this thread for you, someone must have a solution…

I’m starting too with exeoutput, and I’m going to need the POST method too :S

Yep, thanks for testing this for me jayd. My actual software I am building, yes, deals with some MB of data. I was trying that at first. And when I encounter this problem, I tested with just about 100 byte, and still it fails. Plus, the data has been downloaded successfully before I try this Ajax-POST. So it’s more like local-to-local data transfer.

By the way, Form-POST works… just Ajax-POST that’s not working right now. My temporary alternative is to use a form in an iframe for now.

I found out from the General Demo software in EXEOutput

Hahaha okay thanks for this valuable hint :wink: Useful!

Well, at least we tried.

Answered your request by email too.
$_POST works fine except with AJAX in Chromium.
We have a workaround explained in the General Demo that ships with ExeOutput. Please refer to it for the solution.

I have the same problem as well. Ajax workaround worked successfully in version 1.5 and 1.6, but in 1.7 this is not the case. Now what I can see in Developer Tools is that if I send two or more posts to the same address, only the first one is actually sent, and for the next posts “success” part of “$.ajax” is executed, but the return message stays the same as in the first post to this address. In other words, I can only do POST with “$.ajax” in Chromium once.

Now I must return to version 1.5 or 1.6…

It would be great if in the next version this bug can be fixed. I hope that ajax will work normally in Chromium, without workarounds.

1 Like

We are working on next version. We hope to integrate the new CEF release, hoping the AJAX bug will be solved.

1 Like

I’m currently finding this to be a show-stopper issue, I’m unable to get any of our web applications to work with ExeOutput for PHP unless it is possible to achieve an AJAX-style POST-method request in Chromium one way or another without reloading the page. Any news of the next major release with the CEF upgrade?

Also could not find a “general demo” bundled with v1.7? Where can I find this to experiment with the ajax workaround discussed earlier in this topic?

Has anyone found any way to achieve an AJAX post or equivalent in v1.7? Thank you.

You can find the general demo source code in the Public folder, generally at
C:\Users\Public\Documents\ExeOutput for PHP\Samples\generaldemo

AJAX in Chromium will work in ExeOutput 2. See our announcement.