问题
I'm trying to get some data from a server using JavaScript and XMLHttpRequest. The PHP file works every time after refresh (F5) if I view it in the browser. The PHP file is calling a function in a DLL using the 'new DOTNET' method. The function is just a simple one returning a string (Message sent from'TestPHP.dll' version 3).
If I call the same PHP file using XMLHttpRequest (and javascript) it Always works the first time but not the second time. Every second time I receive an "Error callback" (the trird, fifth, ...time works).
Every time the request fails I receive this Error in the Apache Log:
[Sun Feb 09 01:22:51.203412 2014] [mpm_winnt:notice] [pid 4928:tid 400] AH00428: Parent: child process 7992 exited with status 3221225477 -- Restarting.
The error back to the eventhandler in JavaScript I don't know much about. It says it's an Array but I only see ""Error callback", no other message. On error I can see that I never receive "ReadyState" 2 and 3 (only 1 and 4). When it works I have "ReadyState" 1-4.
I'm using WAMP with Apache 2.4.4 and PHP 5.4.12 on Win7 (64 bit).
I don't have any experience using PHP and .NET DLL so sorry for any bad explanation about this problem. I did find a similar post but no answer there.
I don't know what to do or try anymore so any help would me much appreciated,
Thanks!
The PHP file
<?php
header('Content-Type: text/html; charset=UTF-8');
$assembly_string = 'TestPHP, Version=1.0.0.0, Culture=neutral, PublicKeyToken=8e6ebad0ae1c1438';
$class_name = 'TestPHP.TestPHP';
$PHPAsm = new DOTNET($assembly_string, $class_name);
$Result = $PHPAsm->Test();
echo $Result;
?>
Part of the JavaScript
invocation.open("POST", PHPUrl + "?t=" + Math.random(), true);
invocation.onreadystatechange = handler;
invocation.addEventListener("error", function(e) {
alert("Error callback" + objToString(e));
}, false);
invocation.setRequestHeader("Content-Type", "text/plain; charset=UTF-8");
invocation.send(PostData);
来源:https://stackoverflow.com/questions/21653541/error-every-second-time-i-make-a-xmlhttprequest-to-a-php-file-using-dotnet