woodplease Posted September 21, 2010 Share Posted September 21, 2010 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> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/ Share on other sites More sharing options...
dezkit Posted September 21, 2010 Share Posted September 21, 2010 use } else { //code } Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1113819 Share on other sites More sharing options...
woodplease Posted September 22, 2010 Author Share Posted September 22, 2010 i've done that, but it had no effect. i think its to do with the " and ' i've used, but i dont know why. Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1114096 Share on other sites More sharing options...
Chris92 Posted September 22, 2010 Share Posted September 22, 2010 Here's your problem: ajaxpage(''new_section.php'', ''contentarea'') Should be: ajaxpage('new_section.php', 'contentarea') Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1114101 Share on other sites More sharing options...
woodplease Posted September 22, 2010 Author Share Posted September 22, 2010 i've tried that, but it doesnt make any difference Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1114104 Share on other sites More sharing options...
DavidAM Posted September 22, 2010 Share Posted September 22, 2010 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1114204 Share on other sites More sharing options...
woodplease Posted September 23, 2010 Author Share Posted September 23, 2010 i've tried that, but now the php on the page it displays in the div doesnt work. The php reloads the (php) page to INSERT data into a table, using if($_POST ), but it reloads the whole page, not just the div. Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1114422 Share on other sites More sharing options...
Chris92 Posted September 23, 2010 Share Posted September 23, 2010 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> "; ?> Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1114442 Share on other sites More sharing options...
woodplease Posted September 23, 2010 Author Share Posted September 23, 2010 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'); Quote Link to comment https://forums.phpfreaks.com/topic/214026-echoing-ajax/#findComment-1114443 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.