Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If you flush the content (ob_flush) of an AJAX request, the content will get loaded?

I mean... Let's that we just make an AJAX request and inser the result inside a div#result..

In the backend the script use ob_flush() to send the header but not terminate the request until it's terminated (with exit or ob_flush_end)

The content will be loaded into the #result only when the request terminate (exit or ob_flush_end) or it'll be loaded every time the script send the header by ob_flush?

Update:

I'll use jQuery load() to make the request & PHP to answer it

like image 642
Thiago Belem Avatar asked Jan 29 '10 18:01

Thiago Belem


People also ask

What is ob_ flush in PHP?

The ob_flush() function outputs the contents of the topmost output buffer and then clears the buffer of the contents. The output may be caught by another output buffer or, if there are no other output buffers, sent directly to the browser.

What is ob_ start() in wordpress?

Using ob_start allows you to keep the content in a server-side buffer until you are ready to display it. This is commonly used to so that pages can send headers 'after' they've 'sent' some content already (ie, deciding to redirect half way through rendering a page).

What is ob_ start function in PHP?

The ob_start() function creates an output buffer. A callback function can be passed in to do processing on the contents of the buffer before it gets flushed from the buffer. Flags can be used to permit or restrict what the buffer is able to do.


1 Answers

Yes, content will be returned, but the XHR object's readyState will not be set to 4, so if you are relying on that to update your div (which most JS libraries' AJAX auto updaters do), you won't see it automatically.

like image 74
glomad Avatar answered Sep 28 '22 03:09

glomad