What Is The Problem With This Ajax(with Prototype)?
Solution 1:
I'd suggest installing WireShark and monitoring your HTTP traffic to see if you can isolate the problem that way.
Solution 2:
Have you tried another version of Prototype? It seems to me, there's a weird bug in constructing the post request body effectively creating invalid (partly) request the server cannot properly parse. Use Fiddler (easy to grasp http sniffer) and see what exactly is being sent to the server.
If this is not the case (I admit it would be really weird if Prototype would be broken), try reading raw post data via the PHP (should be enabled in php.ini). If you can and they are not populated into the $_POST
collection, try $_REQUEST
instead.
Also, try to consult the following thread, maybe this is your case: http://bugs.php.net/bug.php?id=41349 .
Solution 3:
This is a long shot, but without more information and seeing more of your code I have to ask this so you could rule it out: Could it have something to do with the user double-clicking on the link and creating two rapid requests? (Once upon a time I got bitten by <input type="image" onclick="submit();"> both run the onclick and submitted the form)
function test() {
voteAjax('content','up','89');
voteAjax('content','up','89');
}
(have your link call the test function above)
Normally you want to use asynchronous connections since that won't lock the UI, however this is a case where you could try synchronous to make sure you only do one request at the time. (a nonblocking solution is to set a flag or disable the link/button while the request is processed)
BTW, I too suggest that you send an object instead of a string as the parameters, since prototype will URIEncode it and put all & at the right places.
Solution 4:
I also suggest you should monitor your network traffic through Wireshark:
- Start it on either server or client.
- Start capturing your network interface.
- Use the AJAX and
- when it fails stop the capture and
- type http in Wireshark to help you find the request.
- Right-click and select "Follow TCP Stream".
If POST data in the request does not show up it's something with the browser. You could check HTTP headers for possible errors (like GZip in conjunction with IE has been mentioned before).
Maybe your WAMP setup uses Fast-CGI or similar to call PHP, so it is not using the actual PHP module for Apache? Sometimes this can cause such errors if not set up correctly. If you do not necessarily need it I recommend switching to PHP module or look for possible configuration mistakes.
What WAMP is it, anyway? Pre-configured or custom?
Solution 5:
Try new Date(), instead of random:
voteAjax = function(typez, actionz, idz){
new Ajax.Request(
'http://localhost/reporeade/Vote/Ajax/',
{asynchronous:true,
evalScripts:true,
method:'post',
parameters:'contentType='+typez+'&action='+actionz+'&id='+idz+'&now='+new Date()
});
//alert("params" + typez.toString() + actionz.toString() + idz.toString());
return false;
}
Post a Comment for "What Is The Problem With This Ajax(with Prototype)?"