var xmlHttp = GetXmlHttpObject();
if (xmlHttp == null) {
window.alert("Your browser does not support ajax.\n Please use latest version of your browser.");
return;
}
if (xmlHttp.overrideMimeType)
xmlHttp.overrideMimeType("text/xml");
xmlHttp.open("POST", "signup_server.php", true);
xmlHttp.setRequestHeader("Content-Type",
"application/x-www-form- urlencoded; charset=UTF-8");
var str = "name=n";
xmlHttp.send(str);
xmlHttp.onreadystatechange = function() {
if (xmlHttp.readyState == 4) {
if (xmlHttp.status == 200) {
window.status = xmlHttp.responseText;
}
else
window.alert("Error " + xmlHttp.status + ": " + xmlHttp.statusText);
}
}
Server side code:
Code:
<?php
if (isset($_POST["name"]))
echo $_POST["name"];
else
echo "Name not found.";
?>
After execution, the window.status contains "Name not found." string. Why the server cannot get the name=n? I'm using IIS in Windows XP SP2 and PHP version 5.2.5.
I think the URL called has to be absolute, doesn't it? Also I haven't figured out why, but I had to assign my url to a var first before calling a Perl script. Don't know if this applies to PHP.
Try changing xmlHttp.open("POST", "signup_server.php", true); to xmlHttp.open("POST", "http://www.fullDomainNameHere.com/signup_server.php", true);
I am using IIS 5.1 on Windows XP SP2. When I try to access a php file (using AJAX, a normal php file loads) through firefox 2, firefox wants authentication. After googling I tried several tweaks in about:config, but neither works. This authentication appears in IE 6 too. Most annoying part is, when I enter username and password that I use to log in to Windows, Firefox again pops up same dialog box asking username and password and IE does nothing after entering username and password.
How to get rid of this annoying pop up? Thanks in advance.
I am unable to test AJAX-PHP codes because of the problem (or feature) of Firefox as per post #3 in this thread. I'll be grateful if anyone can solve this problem.
Last edited by PeejAvery; March 27th, 2008 at 12:56 PM.
Reason: Corrections for merged thread.
Bookmarks