PDA

View Full Version : [Dynamic Ajax Content] problem with external PHP script



Bulevardi
12-01-2008, 12:26 PM
1) Script Title: Dynamic Ajax Content

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

3) Describe problem: I load a guestbook in the content, like this:

<a href="javascript:ajaxpage('guestbook.php', 'content');">test</a>
<div id="content"></div>
Works great.
Until I want to add a comment in the book with a form, it doesn't work anymore:

<form action="gbscript.php" method="post" >
... form fields...


gbscript.php adds the comment to a mysql database and than the gbscript needs to load the updated guestbook back in the content:


if($added_to_database) {
include ("guestbook.php");
}

But that last part doesn't work.
If you click the 'send' button on the guestbook form after filling in the form, the gbscript.php starts to load, but there's no result coming back in the content div.

Bulevardi
12-01-2008, 12:57 PM
I also tried to fix the action with that javascript... but didn't work out:



<form action="javascript:ajaxpage('gbscript.php', 'content');" method="post">
... form fields...

instead of this:

<form action="gbscript.php" method="post" >
... form fields...

But then I get the message that the script didn't work.


<?php
if(isset($_POST['submit'])) {
.... this script adds the comments to the database ....
}
else {
echo "The script didn't work";
}
?>

Bulevardi
12-01-2008, 05:24 PM
Is there no possible way to process content to a database via php and get redirected to an updated php file, within that ajax content-div ?

Bulevardi
12-02-2008, 11:19 AM
Do you have to change the ajax script by this:


bustcacheparameter=(url.indexOf("?")!=-1)? "&"+new Date().getTime() : "?"+new Date().getTime()
page_request.open('POST', 'guestbook.php+bustcacheparameter', true)
page_request.send(null)
}

I don't get this whole thing.

Why can't it just run the php script like it should.

I guess it's not the solution to go back to iFrames instead of using this script?
Because with iFrames, my PHP runs perfect.