PDA

View Full Version : Dynamic Ajax Content with ASP



eliven
01-04-2008, 12:48 PM
1) Script Title:
Dynamic Ajax Content

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/ajaxcontent.htm

3) Describe problem:
hi,
i've insert this code to display an asp page into another asp page, the external page has some query to select data from database access. So when i try to view this external page into div I don't see anything.
Is this code incompatible with asp pages?
Thank for help, and i'm sorry for my terrible english.
elisa :)

ddadmin
01-05-2008, 01:42 AM
It shouldn't matter, as Ajax merely is used here to get the results of the page output by your server. If you can view the asp page correctly on its own within the browser, that same URL can be fed to this script and displayed correctly.

eliven
01-16-2008, 11:50 AM
It shouldn't matter, as Ajax merely is used here to get the results of the page output by your server. If you can view the asp page correctly on its own within the browser, that same URL can be fed to this script and displayed correctly.

Why i can't view mine external asp page?
this is my code:

in my head page:
<head>
<script type="text/javascript">

/***********************************************
* Dynamic Ajax Content- Dynamic Drive DHTML code library (www.dynamicdrive.com)
* This notice MUST stay intact for legal use
* Visit Dynamic Drive at http://www.dynamicdrive.com/ for full source code
***********************************************/

var bustcachevar=1 //bust potential caching of external pages after initial request? (1=yes, 0=no)
var loadedobjects=""
var rootdomain="http://"+window.location.hostname
var bustcacheparameter=""

function ajaxpage(url, containerid){
var page_request = false
if (window.XMLHttpRequest) // if Mozilla, Safari etc
page_request = new XMLHttpRequest()
else if (window.ActiveXObject){ // if IE
try {
page_request = new ActiveXObject("Msxml2.XMLHTTP")
}
catch (e){
try{
page_request = new ActiveXObject("Microsoft.XMLHTTP")
}
catch (e){}
}
}
else
return false
page_request.onreadystatechange=function(){
loadpage(page_request, containerid)
}
if (bustcachevar) //if bust caching of external page
bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('GET', url+bustcacheparameter, true)
page_request.send(null)
}

function loadpage(page_request, containerid){
if (page_request.readyState == 4 && (page_request.status==200 || window.location.href.indexOf("http")==-1))
document.getElementById(containerid).innerHTML=page_request.responseText
}

function loadobjs(){
if (!document.getElementById)
return
for (i=0; i<arguments.length; i++){
var file=arguments[i]
var fileref=""
if (loadedobjects.indexOf(file)==-1){ //Check to see if this object has not already been added to page before proceeding
if (file.indexOf(".js")!=-1){ //If object is a js file
fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript");
fileref.setAttribute("src", file);
}
else if (file.indexOf(".css")!=-1){ //If object is a css file
fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet");
fileref.setAttribute("type", "text/css");
fileref.setAttribute("href", file);
}
}
if (fileref!=""){
document.getElementsByTagName("head").item(0).appendChild(fileref)
loadedobjects+=file+" " //Remember this object as being already added to page
}
}
}

</script>

</head>

then in the middle of this page I've this link:

<a href="javascript:ajaxpage('include-messaggio.asp?idm=<%=objRSm("id_messaggio")%>', 'leggiMex');"><%=Anteprima(objRSm("m_soggetto"))%></a>

then I've this div:

<div id="leggiMex"></div>
<div style="clear: left; margin-bottom: 1em"></div>

but when i click on the link i don't see anything?
:(
thanks for your help
elisa

williamstam
05-12-2008, 10:12 AM
did you find your problem? normaly if the asp page errors out it doesnt show in the ajax include container... so make sure you can actualy view your asp page on its own first

almoney
05-30-2008, 07:18 PM
i have a similar problem...my pages are asp with login protection...
i also tried to load css and js for my div content...really don't understand if i only have to loadobjs css and js and no script on the child page...
'cause that example doesn't load an href and a style,js together...but it only loadobjs... maybe that's the problem??? i need href and loadobjs together :)
P.s.: or the problem is with ASP???