PDA

View Full Version : ob_get_contents() problem


clunky
05-27-2010, 02:20 PM
Hi
I was wondering if anyone knows if it is possible to fire this once the page has loaded?
I have two js vars manipulated when an addLoadEvent fires but ob_get_contents() is not getting these new var values, probably due to them not having been created before ob_get_contents() runs.

If it is possible can I add it to my addLoadEvent queue and how?

Cheers

Kor
05-27-2010, 02:24 PM
We have not even the slightest idea. How could we know what the hack ob_get_contents() is?

Post the codes.

Dormilich
05-27-2010, 11:40 PM
it’s a PHP function (of the output buffer) (ref. (http://php.net/ob-get-contents))


and no, you can’t call ob_get_contents() from JavaScript

clunky
05-28-2010, 11:51 AM
Anyway thanks for the, no, can you think of any way of deferring the mail() until after addLoadEvent() events have all finished running please?
Cheers

Dormilich
05-28-2010, 12:05 PM
what mail()? in case you’re talking about PHP’s mail() function … no. unless you make an appropriate AJAX request. (server code is always executed before client code)

clunky
05-28-2010, 12:18 PM
Hi
I ideally would like to use mail() to send my form but unfortunately there are some calcs happening onload, so I am unable to use the ob_get_contents() *hack* due to the mail() sending before page has finished loading.

Can you suggest an ajax or jquery to handle this please?
Cheers

Dormilich
05-28-2010, 12:25 PM
one point to make clear. user events cannot directly affect PHP. PHP happens when a request to the server is made. this is either a page load (actually before the page loads) or an AJAX call.

I have no idea, what this ob_get_contents() hack should be …

if you want to submit your form via email, I recommend sending the form data to the server and build/send the email from there, way more secure and comfortable.

clunky
05-28-2010, 01:08 PM
Hi
ob_get_contents() is not a hack, it is a php content buffer, freely available as you pointed out earlier, enabling you to get content from the page.
It has come in very handy in the past and I have tried to use it once again, but this time due to onload events manipulating the dom it will not work.
ob_get_contents() does its stuff before the page has finished loading so my manipulated stuff do not show up. (all the static stuff works fine)

In the past I used ob_get_contents() to grab the page content and mailed it all off to me, very simple, very quick and unobtrusive.

What I need is to be able to let the page finish doing its stuff then get the finished page content back to me without the users interaction.

Any ideas please?

Dormilich
05-28-2010, 01:21 PM
you can’t do that. JavaScript is only executed in the browser (resp. a JavaScript executing environment), which is not the place you want it to show up.