Re: [PHP] php/ajax question
- From: php@xxxxxxxxxxxxxxx (Mark Kelly)
- Date: Sat, 30 Dec 2006 19:48:05 +0000
On Saturday 30 December 2006 18:56, tedd wrote:
Why can't the php script redirect the browser when called via ajax ?
The browser will not be expecting a page back, and will ignore headers.
Just some quick suggestion code, this isn't tested (except createRequest -
I use that all the time)...
function createRequest() {
try {
request = new XMLHttpRequest();
} catch (trymicrosoft) {
try {
request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (othermicrosoft) {
try {
request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (failed) {
request = null;
}
}
}
if (request == null) alert("Error creating request object!");
}
function sndReq(action) {
createRequest();
var url = "a.php?action=" + Volume + "&dummy=" + new Date().getTime();
// random *** at the end is hack to get round browser response cacheing
request.open("GET",url);
request.onreadystatechange = updateReq;
request.send(null);
}
function updateReq() {
if (request.readyState == 4) {
var newLocation = request.responseText;
window.location = newLocation;
}
}
.
- References:
- php/ajax question
- From: tedd
- php/ajax question
- Prev by Date: php/ajax question
- Next by Date: Re: php/ajax question
- Previous by thread: php/ajax question
- Next by thread: Re: [PHP] php/ajax question
- Index(es):