Article View: pl.comp.lang.javascript
Article #50369Wywołanie funkcji Javascript po wypełnieniu DIVa przez Ajaxa
From: Hesus
Date: Thu, 28 Oct 2010 11:18
Date: Thu, 28 Oct 2010 11:18
118 lines
3108 bytes
3108 bytes
Witajcie.
Kiedyś używałem ramek i wszystko było fajnie ale teraz przesiadłem
się na AJAXa i zaczęły sięschodki.
Mam na stronie dwa DIVy, MENU i TREŚĆ i klikając w przyciski menu
chcę
zmieniać treść bez przeładowywania strony. ale niestety gdy w treści
są jakeiś funkcje JAVA nie wywołują się one. Poratujcie jak to ugryźć
Problem rozwiązał by np DIV OnLoad ale nie ma czegoś takeigo :/
poniżej kod:
INDEX.PHP :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/
TR/xhtml11/DTD/xhtml11.dtd">
<html>
<head>
<title>test</title>
<script language="JavaScript">
<!--
var xmlHttp
function klikniety(str)
{
document.getElementById("tresc").innerHTML="Wczytuje dane ..."
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Przeglądarka nie obsługuje HTTP Request")
return
}
var url=str
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("tresc").innerHTML=xmlHttp.responseText
}
}
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;
}
//-->
</script>
</head>
<body>
<div id="menu">
<input type="Button" onclick="klikniety('strona1.php')"
value="strona1">
<br><BR>
</div>
<div id="tresc">
a kuku
</div>
</body>
</html>
STRONA1.PHP:
to jest jakiś tam tekst a pod nim funkcja alert
<br><br>
<script language="JavaScript">
alert("Aaaaaaa");
</script>
<br><br>
I znowu napis.
Technical Details
Message-ID:
<54d272c8-304d-4ac7-a98f-ebafda11ce44@g25g2000yqn.googlegroups.com>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!g25g2000yqn.googlegroups.com!not-for-mailShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.gazeta.pl!newsfeed.pionier.net.pl!news.glorb.com!postnews.google.com!g25g2000yqn.googlegroups.com!not-for-mail From: Hesus <tomasz.n@op.pl> Newsgroups: pl.comp.lang.javascript Subject: Wywołanie funkcji Javascript po wypełnieniu DIVa przez Ajaxa Date: Thu, 28 Oct 2010 04:18:55 -0700 (PDT) Organization: http://groups.google.com Lines: 121 Message-ID: <54d272c8-304d-4ac7-a98f-ebafda11ce44@g25g2000yqn.googlegroups.com> NNTP-Posting-Host: 87.105.104.84 Mime-Version: 1.0 X-Trace: posting.google.com 1288264735 24189 127.0.0.1 (28 Oct 2010 11:18:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 28 Oct 2010 11:18:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g25g2000yqn.googlegroups.com; posting-host=87.105.104.84; posting-account=x_NVzAoAAAC_Ye4tBsgN5Sjionzoba7q User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; GTB6.6; InfoPath.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe) Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit