![ישן](https://static.fresh.co.il/images/vBulletin/statusicon/post_old.gif)
05-12-2007, 19:31
|
|
|
חבר מתאריך: 05.12.07
הודעות: 29
|
|
AJAX
אז כמו שאתה מבין, זה לא כ"כ קשור לפורום פה. אנחנו תכלס מדברים על JS ולא על PHP.
אבל הנה קוד כללי לקריאת לפונקצית באופן א-סינכרוני
קוד:
script type="text/javascript">
<!--
var xmlHttp;
var div_ID;
function runAJAX(page , div_str )
{
div_ID=div_str;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url=page
url=url+"?sid="+Math.random();
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
//document.getElementById(div_ID).innerHTML = '<img src=''> LOADING ...';
}
function stateChanged()
{
document.getElementById(div_ID).style.display="block"
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById(div_ID).innerHTML=xmlHttp. responseText
}
}
function GetXmlHttpObject()
{
var objXMLHttp=null
if (window.XMLHttpRequest)
{
objXMLHttp=new XMLHttpRequest()
}
else if (window.ActiveXObject)
{
objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP")
}
return objXMLHttp
}
//run the ajax function
//runAJAX(PAGE_TO_LOAD , DIV_ID_TO_SHOW_RESULT)
//-->
</script
>
_____________________________________
==========================================
A working class hero is something to be
==========================================
|