Yellow and Red
Yellow and Red

Reputation: 705

PHP execution - Can I use Ajax method after close connection

I was developing a web application

I am building the PHP part now and I have planned to build the script / AJAX part in the future. like adding sort/category option using AJAX to the application.

Below is how my syntax is

<?php open-connection();?>

    <html> 
         Some html part with sort option
         <script>script part and some AJAX part </script>
    </html>


<?php ob_flush and Close-mysql-connection ?>

will my Ajax /script part works that has access to database depending on the user.

I think after the close connection establishing the ajax will not work. Please guide me.

thanks in advance

Upvotes: 3

Views: 309

Answers (1)

php_nub_qq
php_nub_qq

Reputation: 16055

An ajax call will open a new HTTP connection by it self. It is no different than an ordinary request to your server in terms of connecting. Bare in mind though, that you need to initialize connections to databases again in the script that is to be called dynamically because, as I said, it is treated as a separate request, which it actually is, therefore you need to re-initialize everything that you need to use.

Best of luck! :P

Upvotes: 2

Related Questions