hi,
I am using ajax to load external pages into a div layer... my reason for this is when in a certain section of the site the transition is smooth with no white flash.
my problem is that when a page has been loaded into the div layer I have a custom scroll which i use for div box overflow... the scroller is not being included, my div layers all resort back to the generic standard browser scroll bar. how can i load the external .js ile along with the page as it seems that it will load everything but an external js file
this is the code i use to load the pages in a div -
//link
-
<a href="javascript:void()" onclick="javascript:sendRequest('friends.php', 'connectionsHolder')">Friends</a>
-
-
-
//ajax code
-
function createRequestObject()
-
{
-
var returnObj = false;
-
-
if(window.XMLHttpRequest) {
-
returnObj = new XMLHttpRequest();
-
} else if(window.ActiveXObject) {
-
try {
-
returnObj = new ActiveXObject("Msxml2.XMLHTTP");
-
-
} catch (e) {
-
try {
-
returnObj = new ActiveXObject("Microsoft.XMLHTTP");
-
}
-
catch (e) {}
-
}
-
-
}
-
return returnObj;
-
}
-
-
var http = createRequestObject();
-
var target;
-
-
// This is the function to call, give it the script file you want to run and
-
// the <strong class="highlight">div</strong> you want it to output to.
-
function sendRequest(scriptFile, targetElement)
-
{
-
target = targetElement;
-
try{
-
http.open('get', scriptFile, true);
-
}
-
catch (e){
-
document.getElementById(target).innerHTML = e;
-
return;
-
}
-
http.onreadystatechange = handleResponse;
-
http.send();
-
}
-
-
function handleResponse()
-
{
-
if(http.readyState == 4) {
-
try{
-
var strResponse = http.responseText;
-
document.getElementById(target).innerHTML = strResponse;
-
} catch (e){
-
document.getElementById(target).innerHTML = e;
-
}
-
}
-
}
-
-
-
-
//this is the page code that i am trying to load
-
<?php session_start(); ?>
-
<link href="css/mainCSS.css" rel="stylesheet" type="text/css" />
-
<link href="css/indexCSS.css" rel="stylesheet" type="text/css" />
-
<?
-
include ("admin-dbcon.php");
-
-
$userName = $_SESSION['_amember_user']['login'];
-
$firstName = $_SESSION['_amember_user']['name_f'];
-
$firstName = ucfirst($firstName);
-
$lastName = $_SESSION['_amember_user']['name_l'];
-
$lastName = ucfirst($lastName);
-
-
$commentID=rand(0000000000,9999999999);
-
$dateAdded = gmdate("d M Y H:i:s");
-
$userAV="user/$userName/av/av.jpg";
-
$profilePic="user/$userName/profilePic/profile.jpg";
-
$formLocation="commentsBox";
-
?>
-
<style type="text/css">
-
<!--
-
a:link {
-
color: #FFFFFF;
-
text-decoration: none;
-
}
-
a:visited {
-
text-decoration: none;
-
color: #FFFFFF;
-
}
-
a:hover {
-
text-decoration: underline;
-
color: #E9C100;
-
}
-
a:active {
-
text-decoration: none;
-
color: #FFFFFF;
-
}
-
.style5 {
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
font-size: 12px;
-
font-weight: bold;
-
}
-
.style6 {
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
font-size: 10px;
-
font-weight: bold;
-
color: #666666;
-
text-align: center;
-
}
-
.style7 {
-
font-family: Verdana, Arial, Helvetica, sans-serif;
-
font-size: 14px;
-
font-weight: bold;
-
}
-
.style11 {font-size: 10px}
-
-->
-
</style>
-
-
//it won't load this flexcroll.js along with the whole page and reverts the scroll bar back to the standard browser bar
-
<script type="text/javascript" language="javascript" src="Scripts/flexcroll.js"></script>
-
-
<div id='connectionsFrameHolder' class='flexcroll'>
-
<div style="width:300px; height:auto;">
-
<?
-
mysql_connect($hostname,$username,$password);
-
@mysql_select_db($database) or die( "Unable to select database");
-
-
$sql = "SELECT * FROM friendsList WHERE userName='{$userName}'";
-
$res = mysql_query( $sql ) or die( mysql_error );
-
-
if ( mysql_num_rows( $res ) > 0 ){
-
$row = mysql_fetch_array( $res );
-
-
$str = $row['friendID'];
-
$userID = explode(",",$str);
-
$sts = $row['friendAV'];
-
$userAV = explode(",",$sts);
-
$arrayLength = count($userID);
-
-
for($i=0;$i<$arrayLength;$i++)
-
{
-
echo '<div style="width:300px; height:auto; overflow:visible">';
-
echo '<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">';
-
echo '<tr>';
-
echo '<td width="50" height="50"><img src="Images/noImage.png" height="50" width="50"/></td>';
-
echo '<td width="15"> </td>';
-
echo '<td width="215"><table width="215" border="0" cellspacing="0" cellpadding="0">';
-
echo '<tr>';
-
echo '<td height="50">'.ucwords($userID[$i]) .'<br />
-
location
-
</td>';
-
echo '</tr>';
-
echo '</table></td>';
-
echo '</tr>';
-
echo '</table>';
-
echo '</div>';
-
}
-
}
-
mysql_close();
-
?>
-
</div>
-
</div>
-
5 3567
1. Load the script into the page: - var script = document.createElement("script");
-
// then set the src and append to the head
2. or use eval
3. or have the script already included in the parent page.
i used a ajax tutorial to get that far with my code lol... could you explain that script in a little more detail or show me a place i can learn it?
Once you've created a script element, set the source and add it to the head: - script.src = "file.js";//location of file
-
document.getElementsByTagName("head")[0].appendChild(script);
just an idea i want to pass by you... since the pages that i am loading are php... wouldn't it be easier to use php to echo the script src into the header on load?
That'd work for the initial page, but when using Ajax, the PHP page will be loaded separately, so any JavaScript will have to be evaled or added manually.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Martin |
last post by:
Hello NG,
I've been doing some AJAX for a few weeks now. The basics worked fine so
far, but now I've got the following problem which I can't solve:
With AJAX you typically update/replace only...
|
by: preetksaini |
last post by:
hi
i am having a page in which i have 3 dropdowns,values of 2nd dropdown comes based on 1st and values of 3rd dropdown come based on 2nd.using AJAX+PHP to load dropdowns.
but whenever i refresh...
|
by: Marvin Zhang |
last post by:
Hi,
I'm not familiar with web programming, but I have a problem here.
I have a page. When a user click one button on it, I will use AJAX to
request a PHP script which will do a bunch of tasks,...
|
by: xhunter |
last post by:
I am loading a page using ajax,
but the problem is that the javascript functions existing on that page would no longer be available when loaded through ajax,
is there anyways to load a page in a...
|
by: ofek |
last post by:
Hello,
I've been trying, for the last 3 days, to load an ASCX file, using AJAX, unsuccessfully.
I do as follows:
1. I have an ASPX page that use a javascript function to call a web page.
2....
|
by: sujathaL |
last post by:
Here,i am getting the table from another page by using ajax.i want to get values which are in the table.how to get those values using javascript.
|
by: soms2m |
last post by:
hello all,
I am a just a beginer in this community also to this topic, i want to load a page using ajax. the parent should not be refreshed also its should have a dim background color which one i...
|
by: ton |
last post by:
Hi,
I'm using AJAXPRO this works very well.
What I want to do is to add new page elements at my web site without using a
postback. And I do not mean listitems but a complete dialog. Let me...
|
by: Abubakar |
last post by:
Hi,
I've been assigned to work on a asp.net page that when viewed on internet,
renders very slowly and its hosted on a client machine which is a p4 3.0ghz
HT, with 2 gb ram running windows...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
| |