I have a thing i have made, it works with one function but then does not with two ajax request functions...
This is the layout for the ajax thingy i got
$value = array
(
"id" => $_GET['pid']
);
$url = 'ajax/comment.php';
$divname = 'commentsarea';
$ajax -> Req($value, $url, $divname, "reply");
// I can use it a second time to create a second function
$value = array
(
"id" => $_GET['pid'],
"content" => "'+document.getElementById('contentbox').value+'"
);
$url = 'ajax/comment_submit.php';
$divname = 'submitarea';
$ajax -> Req($value, $url, $divname, "submit");
And it would output
<script type="text/javascript">
function requestObj()
{
var reqObj;
var browser = navigator.appName;
if(browser == "Microsoft Internet Explorer"){
reqObj = new ActiveXObject("Microsoft.XMLHTTP");
}else{
reqObj = new XMLHttpRequest();
}
return reqObj;
}
var http = requestObj();
</script>
<script type="text/javascript">
function reply() {
document.getElementById("commentsarea").innerHTML = "<p align='center'><img src='images/loader.gif' /></p>";
http.open('get', 'ajax/comment.php?id=1&', true);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
document.getElementById("commentsarea").innerHTML = response;
var http = requestObj();
}
}
</script>
<script type="text/javascript">
function submit() {
document.getElementById("submitarea").innerHTML = "<p align='center'><img src='images/loader.gif' /></p>";
http.open('get', 'ajax/comment_submit.php?id=1&content='+document.getElementById('contentbox').value+'&', true);
http.onreadystatechange = handleResponse;
http.send(null);
}
function handleResponse() {
if(http.readyState == 4){
var response = http.responseText;
document.getElementById("submitarea").innerHTML = response;
var http = requestObj();
}
}
</script>But though, it doesnt work? It only works if i had only one, like
$value = array ( "id" => $_GET['pid'] ); $url = 'ajax/comment.php'; $divname = 'commentsarea'; $ajax -> Req($value, $url, $divname, "reply");
Do i need another requestObj() or something? Please help - thanks


Help




Promote to Article

(:








