| | |||||
| ||||||||
| Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics. |
![]() |
| | LinkBack | Thread Tools |
| | THREAD STARTER #1 (permalink) |
| NamePros Regular Join Date: Oct 2005 Location: Milford MA
Posts: 692
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() | |
| |
| | #3 (permalink) |
| NamePros Member Join Date: Mar 2006
Posts: 62
![]() | This AJAX code we use can do both POST/GET. Also, there are available AJAX libraries you can use to simplify the job. Code: function createRequestObject() {
var $vObj;
if (window.XMLHttpRequest) { // Mozilla, Safari,...
$vObj = new XMLHttpRequest();
if ($vObj.overrideMimeType) {
$vObj.overrideMimeType('text/xml');
} // fi
} else if (window.ActiveXObject) { // IE
try {
$vObj = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
$vObj = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
} // fi
if (!$vObj) { // failed, cannot create
return false;
} // fi
} // fi
return $vObj;
}
var $vAJAX = createRequestObject();
var $globAJAXBusy = false;
function checkAJAX() {
if ($globAJAXBusy) {
$vAJAX.onreadystatechange = function () {}
$vAJAX.abort();
} // fi
}
function requestPage($pURL) {
checkAJAX();
$vAJAX.open('GET',$pURL,true);
$globAJAXBusy = true;
$vAJAX.onreadystatechange = handleResponse;
$vAJAX.send(null);
}
function postPage($pURL,$pParams) {
checkAJAX();
$vAJAX.open('POST',$pURL,true);
$globAJAXBusy = true;
$vAJAX.setRequestHeader("Content-type","application/x-www-form-urlencoded");
$vAJAX.setRequestHeader("Content-length",$pParams.length);
$vAJAX.setRequestHeader("Connection","close");
$vAJAX.send($pParams);
$vAJAX.onreadystatechange = handleResponse;
}
function handleResponse() {
if(typeof($vAJAX)=='undefined' || $vAJAX.readyState!=4){
return false;
} // fi
try {
if ($vAJAX.status!=200) { // error page
return false;
} // fi
} catch(e) {
return false;
}
$globAJAXBusy = false;
var $vResult = $vAJAX.responseXML;
..... // do something
}
__________________ 123finder.com - Browse dictionary domains & 4-9 letter domains |
| |
| | #4 (permalink) |
| NamePros Regular Join Date: Mar 2006 Location: Connecticut, USA
Posts: 281
![]() | If you have AJAX code and you don't want people to use the back button, is there a way to disable the backbutton the the Browser or the Mouse if they have one there?
__________________ DarkNeoNetwork |
| |
| | #5 (permalink) |
| Professional Monkey Join Date: Jul 2005 Location: Escaped from the zoo
Posts: 907
![]() ![]() | have you tried the xajax framework? it makes it 10 times easier to creat calls and returns between php and the client side javascript.
__________________ Webmaster Words |
| |