Jump to content

Javascript/Ajax issue


adam84

Recommended Posts

My index page loads both of my JS scripts(ajax.js,functions.js). In that page,I have a table with 3 frame, left,center and right. The center frame's td tag hold a <DIV> tag. The are a list links in the right frame. When the user clicks a link (right frame), ajax loads the page in the center <DIV> tag. In the page that was loaded by the ajax, i have a button and when the button is clicked it called a javascript function located in my JS script file. For some reason, it doesnt seem to link to the JS script files. It always says 'object expected', when I click the button.

 

Once I include my JS file into the main page that is always loaded(index page), wiil I have to include the JS file in any of the page that ajax calls? Or since I already included the JS file already, do I have to include it into the page that the ajax loaded?

 

index page

<?
echo "<HTML>\n";
	echo "<HEAD>\n";
		echo "<TITLE>The Angry Dragon</TITLE>\n";
		echo "<script src=\"jsFunctions.js\" language=\"javascript\" type=\"text/javascript\"></script>\n";
		echo "<script src=\"ajax.js\" language=\"javascript\" type=\"text/javascript\"></script>\n";
	echo "</HEAD>\n";

	echo "<BODY BGCOLOR=\"#FFFFFF\" onLoad=javascript:mainOnLoad();>\n";
		echo "<CENTER>\n";
			echo "<FONT COLOR=\"#000000\"><H1></H1></FONT>\n";
				echo "<TABLE WIDTH=85% BORDER=1>\n";
					echo "<TR>\n";
						echo "<TD WIDTH=20% VALIGN=TOP><TABLE BORDER=1 WIDTH=100%><TR><TD WIDTH=100% VALIGN=TOP><DIV NAME=leftFrame ID=leftFrame></DIV><TD></TR></TABLE></TD>\n";
						echo "<TD WIDTH=60% VALIGN=TOP><TABLE BORDER=1 WIDTH=100%><TR><TD WIDTH=100% VALIGN=TOP><DIV NAME=centerFrame ID=centerFrame></DIV><TD></TR></TABLE></TD>\n";
						echo "<TD WIDTH=20% VALIGN=TOP><TABLE BORDER=1 WIDTH=100%><TR><TD WIDTH=100% VALIGN=TOP><DIV NAME=rightFrame ID=rightFrame></DIV><TD></TR></TABLE></TD>\n";
					echo "</TR>\n";
				echo "</TABLE>\n";
		echo "<CENTER>\n";
	echo "</BODY>\n";
echo "</HTML>\n";
?>

 

Part of the page that gets loaded

echo "<TR>";
echo "<TD VALIGN=MIDDLE ALIGN=CENTER COLSPAN=2>";
echo "<INPUT TYPE=BUTTON NAME=SEARCH ID=SEARCH VALUE='Search' ONCLICK=javascript:archivedSearch();>";
echo "</TD>";
echo "</TR>";

 

Any ideas? On what I can do?

Link to comment
https://forums.phpfreaks.com/topic/41039-javascriptajax-issue/
Share on other sites

I'm not a huge AJAX guy I just started learning. One thing I know from PHP though, I don't even see a need for you to be using php to show any of that. Why not just use html?

<HTML>
<HEAD>
<TITLE>The Angry Dragon</TITLE>
<script src="jsFunctions.js" language="javascript" type="text/javascript"></script>
<script src="ajax.js" language="javascript" type="text/javascript"></script>
</HEAD>

<BODY BGCOLOR="#FFFFFF" onLoad="javascript:mainOnLoad();">
<CENTER>
<FONT COLOR="#000000"><H1></H1></FONT>
<TABLE WIDTH=85% BORDER=1>
  <TR>
<TD WIDTH=20% VALIGN=TOP><TABLE BORDER=1 WIDTH=100%><TR><TD WIDTH=100% VALIGN=TOP><DIV NAME=leftFrame ID=leftFrame></DIV><TD></TR></TABLE></TD>
<TD WIDTH=60% VALIGN=TOP><TABLE BORDER=1 WIDTH=100%><TR><TD WIDTH=100% VALIGN=TOP><DIV NAME=centerFrame ID=centerFrame></DIV><TD></TR></TABLE></TD>
<TD WIDTH=20% VALIGN=TOP><TABLE BORDER=1 WIDTH=100%><TR><TD WIDTH=100% VALIGN=TOP><DIV NAME=rightFrame ID=rightFrame></DIV><TD></TR></TABLE></TD>
  </TR>
</TABLE>
<CENTER>
</BODY>
</HTML>

Add to that all of the table and td declarations should be in ""

Link to comment
https://forums.phpfreaks.com/topic/41039-javascriptajax-issue/#findComment-199035
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.