Jump to content

echoing ajax


woodplease

Recommended Posts

i'm not sure whether this should be in this section or the ajax section.

 

i'm trying to echo out an ajax script so that a page loads in a div tag after a link is clicked in the menu.

Without the "echo", it works fine, but as soon as i include it within the "echo", it stops working. Any help would be great

else echo"

<div id='fcontrol'>

<table border='1' class ='tstyle'>
<tr height ='700'><td valign='top' class='ssbg' width='120'><div id='menu'>

<a href='javascript:ajaxpage(''new_section.php'', ''contentarea'');'>Add new section</a><br/><br/>
<a href='javascript:ajaxpage('new_sub_section.php', 'contentarea');'>Add new section to forum</a><br/><br/><a href='index.php'>Back to forum</a><br/><br/></div></td><td class='tcontrol' width='700' valign='top'>
<center><div id='contentarea'>Control Panel</div></center></td></tr>
</table></div>

</div>
"; ?>

 

Link to comment
Share on other sites

It might be easier to drop out of PHP to output that code (and cleanup the quotes):

else { ?>

<div id='fcontrol'>

<table border='1' class ='tstyle'>
<tr height ='700'><td valign='top' class='ssbg' width='120'><div id='menu'>

<a href="javascript:ajaxpage('new_section.php', 'contentarea');">Add new section</a><br/><br/>
<a href="javascript:ajaxpage('new_sub_section.php', 'contentarea');">Add new section to forum</a><br/><br/>
<a href='index.php'>Back to forum</a><br/><br/></div></td><td class='tcontrol' width='700' valign='top'>
<center><div id='contentarea'>Control Panel</div></center></td></tr>
</table></div>

</div>
<?php
}
?>

Link to comment
Share on other sites

else echo"

<div id=\"fcontrol\">

<table border=\"1\" class=\"tstyle\">
<tr height=\"700\"><td valign=\"top\" class=\"ssbg\" width=\"120\"><div id=\"menu\">

<a href=\"javascript:ajaxpage('new_section.php', 'contentarea');\">Add new section</a><br/><br/>
<a href=\"javascript:ajaxpage('new_sub_section.php', 'contentarea');\">Add new section to forum</a><br/><br/><a href=\"index.php\">Back to forum</a><br/><br/></div></td><td class=\"tcontrol\" width=\"700\" valign=\"top\">
<center><div id=\"contentarea\">Control Panel</div></center></td></tr>
</table></div>

</div>
"; ?>

Link to comment
Share on other sites

thanks, but i have a problem with the (php) page that displays in the div.

There is a form in the php page that when submitted, reloads the php page, and runs code to insert the form data into a table. the problem is that it is reloading the page with the ajax on, therefore the php page is no longer loaded in the div resulting in the code not running.

 

the code on the form (of the php page) that reloads the page is

<form name="add_section" method="post" action="<?php echo $_SERVER['../PHP_SELF']; ?>">

 

when the page reloads, its uses

if (isset($_POST['new_section'])) { 
if (!$section_title ) {
die('You did not complete all of the required fields<br/><a href="./new_section.php">Back</a>');
}
$query = "INSERT INTO section_main (section_title) VALUES ('$section_title')";
$add_section = mysql_query($query) or die ('could not add new section');

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.