> well. I read in the docs that pure javascript returned gets eval'd and
> processed, but that isn't what I am experiencing.

Those same docs[1] say that it's turned off by default. ;-) You need
to specify `evalScripts: true` in the options you pass into
`Ajax.Updater` to tell it to turn it on.

But you have another problem: Your script is calling `document.write`.
You can't use `document.write` after the initial parsing of the page
is done (or rather, you *can*, but it won't do what you want it to do
-- instead, it will completely tear down the entire page and start a
new one). Just have the PHP output the actual HTML you want to use,
rather than outputting script that then outputs HTML. If you need to
output something different based on a client-side piece of
information, either pass that information to your PHP script and
handle the branching there, or have the result return placeholder
elements that you then update by making calls to Prototype's
`Element#update` and such. Here's a gratuitous example: http://jsbin.com/ofate4

[1] http://api.prototypejs.org/ajax/Ajax/Updater/

T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com

On Apr 7, 4:41 pm, cszalaj <csza...@gmail.com> wrote:
> We are using the Ajax.updater.  A php script determines the response
> that is returned to the updater to be passed to the <div> for
> updating. In the case that the success message is returned upon
> successful form submission, we need some javascript to be processed as
> well. I read in the docs that pure javascript returned gets eval'd and
> processed, but that isn't what I am experiencing. The php function
> that returns the script is:
> public function etag_thanksQuickContact(&$domDoc) {
>     return '<script type="application/
> javascript">document.write("<h1>Thank You</h1><p>Thank you for
> contacting us.</p>");</script>';
>   }
> This is simplified to for testing purposes. The real script that I
> want eval'd will include a few other statements, but I am using this
> to make sure that the script is running properly.
> The Ajax.updater javascript we have is:
> function qcSubmit() {
>   new Ajax.Updater('qcContent', '/h/contact/QuickContact', {
>     parameters: {
>       name: $F('name'),
>       email: $F('email'),
>       telephone: $F('telephone'),
>       comment: $F('comment')
>     }
>   });
> }
> If I write the PHP function to just return the thank you text, and not
> a javascript that prints it, then it returns fine. When I try to write
> it with Javascript, it isn't eval'ing. What do I need to do
> differently?

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
For more options, visit this group at 

Reply via email to