call page using AJAX
Posted: Tue Aug 28, 2007 6:02 am
feyd | Please use
but verConfig.php have included a "refresh" button that call this javascript function
this function will call the same page and pass those values into it, but now i have the verConfig.php page included into another page. the problem is that if a call refreshConfig function the "main" page will disapper and the verConfig.php is the one left.
so i'm trying to solve this problem using ajax, is there any way to use this to call the page again, without refreshing the "main" page only the included one (verConfig.php) ??
this is the only idea that i have, if someone have a better one please reply
thanks in advance
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
hi.
i'm using this line to include a php page into a "main" oneCode: Select all
require_once 'verConfig.php';Code: Select all
<script type="text/javascript">
function refreshConfig (cfg) {
size = document.config.elements.length;
ctent = "";
for (i=1; i < size; i++){
ctent = ctent + document.config.elements[i].value +",";
}
ctent = ctent.substr(0,ctent.length-1);
if ( value ) {
location.href = "verConfig.php?c=<?=$c?>&calc=2&arrProd="+ctent;
} else {
location.href = "verConfig.php?c=<?=$c?>&calc=1&arrProd="+ctent;
}
}
</script>
so i'm trying to solve this problem using ajax, is there any way to use this to call the page again, without refreshing the "main" page only the included one (verConfig.php) ??
Code: Select all
function GetXmlHttpObject() {
var xmlHttp = null;
try {
// Firefox, Opera 8.0+, Safari
xmlHttp = new XMLHttpRequest();
} catch (e) {
// Internet Explorer
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
}
function updatePage() {
if (xmlHttp.readyState == 4) {
var response = xmlHttp.responseText;
document.getElementById("element").value = response;
}
}
function calcConfig(...) {
try {
size = document.config.elements.length;
ctent = "";
for (i=1; i < size; i++){
ctent = ctent + document.config.elements[i].value +",";
}
ctent = ctent.substr(0,ctent.length-1);
if ( value ) {
location.href = "verConfig.php?c=<?=$c?>&calc=2&arrProd="+ctent;
} else {
location.href = "verConfig.php?c=<?=$c?>&calc=1&arrProd="+ctent;
}
xmlHttp.onreadystatechange = updatePage;
xmlHttp.open("GET",url,true);
xmlHttp.send(null);
} catch (e) { }
}
thanks in advance
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]